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 選項。 |
這有幫助嗎?