> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJkOTY5YmY3Mi1hZTk0LTRiNjUtYTYzNy0yMGZlOTE2YThlZDkiLCJleHAiOjE3ODEzNDI2MjEsImlhdCI6MTc4MTM0MjMyMX0.G0GNmeyfXq8AXVQKHgLStdDBVi-TJyDKtHboFZd0LHo
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 自定义 robots.txt

> 在您的文档站点根目录提供自定义 robots.txt 来控制搜索引擎和 AI 爬虫如何访问您的内容。

默认情况下，Fern 在您的文档站点根目录提供一个自动生成的 `robots.txt`，允许所有爬虫并指向您的 `sitemap.xml`。使用 [`docs.yml` 中的 `agents.robots-txt` 键](/learn/docs/configuration/site-level-settings#agentsrobots-txt) 来提供您自己的文件——这对于选择接受或拒绝特定的 AI 爬虫、限制敏感部分或使用 [Cloudflare 内容信号策略](https://blog.cloudflare.com/content-signals-policy/) 表明偏好非常有用。

`robots.txt` 只是建议性的：合规的爬虫会遵循您的 `Disallow` 和 `Allow` 指令，但忽略协议的机器人仍然可以访问这些路径。对于必须保持私有的内容，[请使用身份验证](/learn/docs/authentication/overview)。

`robots.txt` 决定哪些爬虫可以访问您的站点以及您广播什么 AI 训练信号。它的配套文件 [`llms.txt`](/learn/docs/ai-features/llms-txt) 则影响 AI 代理爬取后接收到的内容。

## 配置

```yaml docs.yml
agents:
  robots-txt: ./robots.txt
```

路径是相对于 `docs.yml` 的。

```txt robots.txt
# 允许搜索引擎
User-Agent: Googlebot
Allow: /

# 限制 AI 爬虫访问私有路径
User-Agent: GPTBot
Disallow: /private

# 通过 Cloudflare 内容信号声明 AI 使用偏好
Content-Signal: ai-train=yes, search=yes, ai-input=yes

# 为爬虫指向您的站点地图——Fern 的默认 robots.txt 包含此项，
# 所以在用自定义文件替换默认文件时需要添加回来
Sitemap: https://docs.example.com/sitemap.xml
```

将命名的机器人（如 `GPTBot`、`Googlebot`）放在文件中任何通配符组之前——Fern 在提供文件时会附加自己的 `User-Agent: *` 块。

您的文件会在 `/robots.txt` 原样提供。Fern 会在末尾附加一个托管块，禁止内部 API 路由：

```txt
# Fern 托管的路由——自动禁止
User-Agent: *
Disallow: /api/fern-docs/
```