详细分析 ▾
运行时依赖
版本
Automated batch sync
安装命令
点击复制技能文档
指导如何为搜索引擎和 AI 爬虫配置并审计 robots.txt。
首次调用时,如有助于理解,先用 1–2 句话说明本技能覆盖范围及其重要性,再给出主体输出。 后续调用或用户要求跳过时,直接进入主体输出。
范围(技术 SEO)
- robots.txt:配置 Disallow/Allow、Sitemap、Clean-param;审计意外屏蔽
- 爬虫访问:路径级抓取控制;AI 爬虫允许/屏蔽策略
- 区分:robots.txt = 抓取控制(谁访问哪些路径);noindex = 索引控制(哪些内容被索引)。页面级排除请参见 indexing
初始评估
优先检查项目上下文:若存在.claude/project-context.md 或 .cursor/project-context.md,先读取其中的站点 URL 与索引目标。识别:
- 站点 URL:基础域名(如
https://example.com) - 索引范围:整站、部分或需排除的特定路径
- AI 爬虫策略:允许搜索/索引 vs 屏蔽训练数据爬虫
最佳实践
目的与限制
| 要点 | 说明 | |------|------| | 目的 | 控制爬虫访问;不能阻止索引(被屏蔽的 URL 仍可能出现在搜索结果但无摘要) | | 声明性 | 规则仅为建议;恶意爬虫可忽略 | | 公开 | robots.txt 可被公开读取;敏感内容请用 noindex 或鉴权。参见 indexing |抓取 vs 索引 vs 链接权重(速查)
| 工具 | 控制 | 阻止索引? | |------|----------|-------------------| | robots.txt | 抓取(路径级) | 否——被屏蔽 URL 仍可能出现在 SERP | | noindex(meta / X-Robots-Tag) | 索引(页面级) | 是。参见 indexing | | nofollow | 仅链接权重 | 否——不控制索引 |何时用 robots.txt vs noindex
| 场景 | 工具 | 示例 | |-----|------|---------| | 路径级(整个目录) | robots.txt |Disallow: /admin/, Disallow: /api/, Disallow: /staging/ |
| 页面级(特定页) | noindex meta / X-Robots-Tag | 登录、注册、感谢页、404、法律页。完整列表参见 indexing |
| 关键 | 勿在 robots.txt 屏蔽 | 使用 noindex 的页面——爬虫必须访问页面才能读取指令 | 应在 robots.txt 屏蔽的路径:/admin/、/api/、/staging/、临时文件。 应使用 noindex(允许抓取):/login/、/signup/、/thank-you/ 等——参见 indexing。
位置与格式
| 项目 | 要求 | |------|-------------| | 路径 | 站点根目录:https://example.com/robots.txt |
| 编码 | UTF-8 纯文本 |
| 标准 | RFC 9309(Robots Exclusion Protocol) | 核心指令
| 指令 | 目的 | 示例 | |-----------|---------|---------| |User-agent: | 目标爬虫 | User-agent: Googlebot, User-agent: * |
| Disallow: | 屏蔽路径前缀 | Disallow: /admin/ |
| Allow: | 允许路径(可覆盖 Disallow) | Allow: /public/ |
| Sitemap: | 声明 sitemap 绝对地址 | Sitemap: https://example.com/sitemap.xml |
| Clean-param: | 去除查询参数(Yandex) | 见下方 | 关键:切勿屏蔽
| 切勿屏蔽 | 原因 | |--------------|--------| | CSS、JS、图片 | Google 需要它们渲染页面;屏蔽会破坏索引 | |/_next/(Next.js) | 会中断 CSS/JS 加载;GSC 中“已抓取 - 未索引”对静态资源属正常现象。参见 indexing |
| 使用 noindex 的页面 | 爬虫必须访问页面才能读取 noindex 指令;在 robots.txt 屏蔽会阻止这一过程 | 仅屏蔽:无需抓取的路径:/admin/、/api/、/staging/、临时文件。
AI 爬虫策略
robots.txt 对所有已测 AI 爬虫均有效(Vercel/MERJ 研究,2024)。按 user-agent 设置规则;查阅各厂商文档获取最新令牌。| User-agent | 目的 | 常见 | |------------|---------|---------| | OAI-SearchBot | ChatGPT 搜索 | Allow | | GPTBot | OpenAI 训练 | Disallow | | Claude-SearchBot | Claude 搜索 | Allow | | ClaudeBot | Anthropic 训练 | Disallow | | PerplexityBot | Perplexity 搜索 | Allow | | Google-Extended | Gemini 训练 | Disallow | | CCBot | Common Crawl(LLM 训练) | Disallow | | Bytespider | ByteDance | Disallow | | Meta-ExternalAgent | Meta | Disallow | | AppleBot | Apple(Siri、Spotlight);可渲染 JS | 为索引可 Allow |
Allow vs Disallow:允许搜索/索引机器人(OAI-SearchBot、Claude-SearchBot、PerplexityBot);若不希望内容被用于模型训练,则屏蔽纯训练机器人(GPTBot、ClaudeBot、CCBot)。AI 爬虫优化(SSR、URL 管理)参见 site-crawlability。
Clean-param(Yandex)
``
Clean-param: utm_source&utm_medium&utm_campaign&utm_term&utm_content&ref&fbclid&gclid
`` 输出格式
- 当前状态(如为审计)
- 推荐 robots.txt(完整文件)
- 合规检查清单
- 参考资料:Google robots.txt
相关技能
- indexing:完整 noindex 页面类型列表;何时用 noindex vs robots.txt;GSC 索引诊断
- page-metadata:Meta robots(noindex、nofollow)实现
- xml-sitemap:在 robots.txt 中引用的 sitemap URL
- site-crawlability:更广的抓取与结构指导;AI 爬虫优化
- rendering-strategies:SSR、SSG、CSR;确保爬虫可获取初始 HTML 内容