Menu

htmlLimitedBots

htmlLimitedBots 配置允许你指定一个用户代理列表,这些用户代理将接收阻塞元数据,而不是流式元数据

next.config.ts
TypeScript
import type { NextConfig } from 'next'
 
const config: NextConfig = {
  htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,
}
 
export default config

默认列表

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

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

查看完整列表点击这里

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

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

禁用

要完全禁用流式元数据:

next.config.ts
import type { NextConfig } from 'next'
 
const config: NextConfig = {
  htmlLimitedBots: /.*/,
}
 
export default config

版本历史

VersionChanges
15.2.0引入 htmlLimitedBots 选项。