Skip to content

htmlLimitedBots

htmlLimitedBots 配置允许你指定应接收阻止元数据而不是 流元数据 的用户代理列表。

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

ts
import type { NextConfig } from 'next'

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

export default config

默认列表

¥Default list

Next.js 包含一个默认的 HTML 限制型机器人列表,其中包括:

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

  • Google 爬虫(例如 Mediapartners-Google、AdsBot-Google、Google-PageRenderer)

    ¥Google crawlers (e.g. Mediapartners-Google, AdsBot-Google, Google-PageRenderer)

  • Bingbot

  • Twitterbot

  • Slackbot

请参阅 此处 的完整列表。

¥See the full list here.

指定 htmlLimitedBots 配置将覆盖 Next.js 的默认列表。但是,这是高级行为,默认值应该足以满足大多数情况。

¥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.

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

export default config

禁用

¥Disabling

要完全禁用流式元数据:

¥To fully disable streaming metadata:

ts
import type { NextConfig } from 'next'

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

export default config

版本历史

¥Version History

版本更改
15.2.0引入 htmlLimitedBots 选项。