N Next.js 中文
原文 ↗

htmlLimitedBots

指定应接收阻塞式元数据的用户代理列表。

更新于 2025-10-03Next.js 16.4.6

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

TypeScript

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

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

export default config

JavaScript

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

默认列表

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

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

查看完整列表。

指定 htmlLimitedBots 配置将覆盖 Next.js 的默认列表。不过,这属于高级行为,在大多数情况下默认值已经足够。

TypeScript

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

export default config

JavaScript

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

禁用

要完全禁用流式元数据:

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

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

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

版本历史

版本 变更
15.2.0 引入 htmlLimitedBots 选项。