Skip to main content

htmlLimitedBots

还没翻译译自英文(nextjs.org)本页 11 段都还没译

The htmlLimitedBots config allows you to specify a list of user agents that should receive blocking metadata instead of streaming metadata.

next.config.ts
import type { NextConfig } from 'next'

const config: NextConfig = {
  htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,
}

export default config
next.config.js
module.exports = {
  htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,
}

Default list

Next.js includes a default list of HTML limited bots, including:

  • Google crawlers (e.g. Mediapartners-Google, AdsBot-Google, Google-PageRenderer)
  • Bingbot
  • Twitterbot
  • Slackbot

See the full list here.

Specifying a htmlLimitedBots config will override the Next.js' default list. However, this is advanced behavior, and the default should be sufficient for most cases.

next.config.ts
const config: NextConfig = {
  htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,
}

export default config
next.config.js
module.exports = {
  htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,
}

Disabling

To fully disable streaming metadata:

next.config.ts
import type { NextConfig } from 'next'

const config: NextConfig = {
  htmlLimitedBots: /.*/,
}

export default config
next.config.js
module.exports = {
  htmlLimitedBots: /.*/,
}

Version History

VersionChanges
15.2.0htmlLimitedBots option introduced.