htmlLimitedBots
htmlLimitedBots 配置允许您指定一个用户代理列表,这些代理应接收阻塞元数据而不是流式元数据。
next.config.ts
import type { NextConfig } from 'next'
const config: NextConfig = {
htmlLimitedBots: /MySpecialBot|MyAnotherSpecialBot|SimpleCrawler/,
}
export default config默认列表
Next.js 包含一个默认的 HTML 限制机器人列表,包括:
- 谷歌爬虫(例如 Mediapartners-Google、AdsBot-Google、Google-PageRenderer)
- Bingbot
- Twitterbot
- Slackbot
查看完整列表这里。
指定 htmlLimitedBots 配置将覆盖 Next.js 的默认列表。但是,这是高级行为,对于大多数情况来说,默认值应该足够了。
next.config.ts
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版本历史
| 版本 | 更改 |
|---|---|
| 15.2.0 | 引入了 htmlLimitedBots 选项。 |
这有帮助吗?