← 知识整理
出海增长 / 知识整理 · 中文

抓取与索引控制完全指南 (robots.txt / noindex / X-Robots-Tag / data-nosnippet / rel)

Google 抓取/索引/呈现 3 层控制心智模型。robots.txt(只控抓取,不控索引)+ 3 大限制。noindex(meta tag + HTTP header)实施 + 调试。robots meta tag 11 条 valid rules + 3 条 historical 全表。data-nosnippet 元素级精细控制。X-Robots-Tag (Apache/NGINX 配置 + 正则适配非 HTML)。冲突取最严。robots.txt + noindex 互相残杀的经典坑。控制内容 4 大方法决策表。移除图片专项(Googlebot-Image UA)。9 个 user-triggered fetcher 全列表(忽略 robots.txt)。rel=sponsored/ugc/nofollow 出站链接限定符。

资料来源:Google 搜索与 SEO · 本站发布:2026-09-26

SEO搜索引擎自然增长

一句话心智模型: Google 对你的内容有 3 个独立操作:Crawl(爬不爬)→ Index(收不收录)→ Serve(怎么展示)。每层有不同的控制工具,搞混了就会自相矛盾。

TL;DR — 3 层控制对照表 ⭐⭐⭐

你想 用什么 在哪里实施
不让 Google 爬(省服务器) robots.txt 的 Disallow: 站根 /robots.txt
可以爬但不要收录到搜索结果 noindex <meta name="robots"> 或 X-Robots-Tag HTTP header
可以收录但限制呈现方式(限 snippet/preview/翻译/过期 etc.) nosnippet / max-snippet: / max-image-preview: / notranslate / unavailable_after: meta tag 或 HTTP header
可以索引但段内某些文字不进 snippet data-nosnippet HTML 属性 页面里的 <span> / <div> / <section>
某条链接不传 PageRank rel="nofollow" / sponsored / ugc <a> 标签
彻底不公开(数据安全) 密码保护 / 删掉 服务器层

⚠️ 致命经典坑

用 robots.txt Disallow 一个页 ≠ 这个页不会出现在搜索结果。

Google 不会爬它,但如果别的站链接到它,Google 仍可能把 URL 写进搜索结果(没有 description,只有干巴巴的 URL)。要真的不出现 → 用 noindex 或密码保护。

更糟的:你先 robots.txt Disallow 又加 noindex → Google 永远爬不到这页 → 永远看不到 noindex → 这页一直出现在搜索结果。robots.txt 和 noindex 互斥。


Part 1 — robots.txt 的真正用途

1.1 主要用途(2 件)

  1. 管理抓取流量 — 不让某些路径被频繁爬,省服务器
  2. (只对媒体文件)从搜索结果剔除 — 图片/视频/音频用 robots.txt block 才能不出现在 Google Images/Videos

1.2 ⚠️ robots.txt 不是的东西

  • ❌ 不是隐藏页面的机制
  • ❌ 不是安全机制(Google 守规矩,其他爬虫不一定)
  • ❌ 不是 noindex 的替代品

1.3 文件类型行为差异

文件类型 robots.txt Disallow 的效果
Web page(HTML/PDF/文本) ⚠️ 只阻止爬,不阻止显示:如果别处链接到它,URL 还是会出现在搜索结果(无 description)。要彻底不显示用 noindex 或密码保护。
媒体文件(图/视/音) ✅ 真的不会出现在 Google Images/Videos。但别人的页面链接到你的图,他们可以正常嵌入显示。
资源文件(JS/CSS/不重要图) ⚠️ 只在"页面没了这些资源也基本不影响阅读"时 block。如果资源影响 Google 理解页面 → 不要 block,否则 Google 渲染不出来 → 索引质量降。

1.4 3 大根本限制

  1. 不是所有搜索引擎都遵守 — Google/Bing 等守规矩,很多爬虫和 AI 抓手不守
  2. 不同爬虫语法解析不同 — 同一条规则在 Google 和别的引擎可能行为不同
  3. 被 disallow 的页仍可被索引 — 见上面的"致命坑"

1.5 创建/更新

CMS 用户(WordPress/Wix/Blogger):多数 CMS 已经做了,不要手动改。找你 CMS 的 "search settings" 页面。


Part 2 — noindex: 不进搜索结果的正解

2.1 关键前提 ⭐

noindex 要生效,页面必须是可被爬的。

  • ❌ robots.txt Disallow 这个页 → Google 看不到 noindex → 页可能依然出现在结果
  • ❌ 加 noindex 但页面挂了 / 502 → Google 也看不到 → 无效
  • ✅ 必须 allow 爬 + 加 noindex 才有效

2.2 两种实施方式(选一即可,不要同时用)

A. <meta> 标签(最常用,HTML 页适用)

<meta name="robots" content="noindex">

只针对 Google:

<meta name="googlebot" content="noindex">

注: Google 不强制 meta 必须放在 <head> 里,放 <body> 里也认。但其他搜索引擎不一定,老老实实放 <head> 里。

B. X-Robots-Tag HTTP 响应头(非 HTML 文件唯一选:PDF/视频/图片)

HTTP/1.1 200 OK
(...)
X-Robots-Tag: noindex
(...)

⚠️ robots.txt 里写 Noindex: 不被 Google 支持。别试。

2.3 调试 noindex 没生效的 3 大原因

  1. Google 还没重爬这页 — 重要性低的页可能数月才被重爬一次。用 URL Inspection tool 请求 recrawl。
  2. robots.txt 把这页 block 了 — 见 2.1。改 robots.txt allow 爬。
  3. noindex 没真的对 Googlebot 暴露 — 用 URL Inspection tool 看 Googlebot 实际收到的 HTML 是啥(不是看你浏览器看到的)。

2.4 监控

Search Console → Page Indexing report 可以监控哪些页因 noindex 被剔除。


Part 3 — robots meta tag 的 11 条 valid rules ⭐⭐⭐

3.1 完整规则表

规则 作用
all 默认,无限制
noindex 不索引这页
nofollow 不跟随这页里的链接(独立于索引)
none = noindex, nofollow 简写
nosnippet 不显示 text snippet / video preview。也禁止内容被用作 AI Overviews / AI Mode 的直接输入。静态图缩略图可能仍出现(如果有助 UX)
indexifembedded ⭐ 允许索引嵌在别人页 iframe 里的版本,即便本页有 noindex。必须和 noindex 一起用才生效
max-snippet: N snippet 最多 N 字符。0 = nosnippet,-1 = Google 自决长度。也限制 AI Overviews/Mode 能用多少
max-image-preview: [none/standard/large] 图片预览大小
max-video-preview: N video snippet 最多 N 秒。0 = 仅静态图,-1 = 无限制
notranslate 不在搜索结果里提供翻译版
noimageindex 不索引这页的图(其他页里出现的同图,仍可能被那些页索引)
unavailable_after: [date] 到期后不显示在搜索结果。日期支持 RFC 822 / RFC 850 / ISO 8601

3.2 已废弃 / 不再生效的 3 条 historical rules

规则 状态
noarchive 不再使用 — cached link 功能没了
nocache 从来不用
nositelinkssearchbox 不再使用 — sitelink search box 功能没了

3.3 组合多条规则

逗号分隔(等价):

<meta name="robots" content="noindex, nofollow">

多个 meta 标签:

<meta name="robots" content="noindex">
<meta name="robots" content="nofollow">

多个不同 crawler 名 — Google 取所有负向规则的并集:

<meta name="robots" content="nofollow">
<meta name="googlebot" content="noindex">

→ Googlebot 把这页当作 noindex, nofollow。

3.4 冲突取最严

<meta name="robots" content="max-snippet:50, nosnippet">

→ nosnippet 胜出(更严)。

3.5 ⭐ structured data 不受 robots meta 限制

max-snippet 等限制只对 Google 自动从页面抽取的内容 生效。通过 structured data 主动声明的内容,绕过这些限制。

  • 想限制 recipe rich result 的 description 长度 → 改 structured data 自己,不是改 robots meta
  • 想从 article.description / 其他 creative work 的 description 限制长度 → 用 max-snippet(这是例外,因为这俩字段 Google 把它当 snippet)
  • data-nosnippet 包裹的 structured data 块 → 仍可用于搜索结果(不被排除)

Part 4 — data-nosnippet: 元素级精细控制

4.1 作用

页面内某一段文字不进 snippet,但页面整体仍可索引。

4.2 语法规则

  • 只能用在 <span> / <div> / <section> 上
  • 是 boolean attribute — 写 data-nosnippet、data-nosnippet=""、data-nosnippet="true"、data-nosnippet="false" 都视为打开(boolean 属性的特性)
  • HTML 必须合法 — 标签必须正确闭合,否则 Google 解析时可能把后续全部内容也排除

4.3 示例

<p>This text can be shown in a snippet
<span data-nosnippet>and this part would not be shown</span>.</p>

<div data-nosnippet>not in snippet</div>
<div data-nosnippet="true">also not in snippet</div>
<div data-nosnippet="false">also not in snippet</div>
<!-- 所有值都被视为 "打开" -->

4.4 ⚠️ JS 动态加 data-nosnippet 的坑

Google 渲染前/渲染后都可能提取 data-nosnippet。不要用 JS 动态加/删 data-nosnippet 属性(因为渲染前抽取那次,你的 JS 还没跑)。

正确做法: DOM 元素初次写入页面时就带上 data-nosnippet,后续不改。

自定义元素: 必须用 <div>/<span>/<section> 包裹或渲染 才能用 data-nosnippet。<mytag data-nosnippet> 无效。


Part 5 — X-Robots-Tag HTTP 响应头

5.1 为什么用它

  • 非 HTML 资源(PDF/图/视频)唯一选项,因为没法写 <meta> 标签
  • 想全站统一施加规则时,比逐页加 meta 好维护
  • 支持正则匹配文件 → 灵活

5.2 配置示例

Apache — 全站所有 PDF noindex+nofollow:

<Files ~ "\.pdf$">
Header set X-Robots-Tag "noindex, nofollow"
</Files>

NGINX — 同上:

location ~* \.pdf$ {
add_header X-Robots-Tag "noindex, nofollow";
}

Apache — 全站所有图片 noindex:

<Files ~ "\.(png|jpe?g|gif)$">
Header set X-Robots-Tag "noindex"
</Files>

单文件:

# .htaccess 必须放在文件所在目录
<Files "unicorn.pdf">
Header set X-Robots-Tag "noindex, nofollow"
</Files>

5.3 多个 X-Robots-Tag 组合

两种等价写法:

X-Robots-Tag: noimageindex
X-Robots-Tag: unavailable_after: 25 Jun 2010 15:00:00 PST

或者:

X-Robots-Tag: noimageindex, unavailable_after: 25 Jun 2010 15:00:00 PST

5.4 指定 user-agent

X-Robots-Tag: googlebot: nofollow
X-Robots-Tag: otherbot: noindex, nofollow

不指定 user-agent → 对所有爬虫生效。

HTTP header 名、user-agent 名、规则值 都大小写不敏感。


Part 6 — robots.txt + meta robots 一起用的坑 ⭐⭐⭐

6.1 核心冲突

如果一个 URL 被 robots.txt Disallow:

  • Googlebot 永远爬不到 → 永远看不到 <meta name="robots" content="noindex"> 或 X-Robots-Tag: noindex
  • → 这页仍可能被索引(基于外链,无 description)
  • → 你以为加了 noindex 万事大吉,实际上完全失效

6.2 决策树

要不要 noindex?
├─ 是 → robots.txt 必须 Allow 这个 URL (或不写 Disallow)
│         → 加 <meta robots noindex> 或 X-Robots-Tag: noindex
│         → 等 Googlebot 重爬看见
│
└─ 只是省服务器流量(不在乎索引)
          → robots.txt Disallow 就好
          → 接受这页 URL 可能仍出现在结果里(无 description)
          → 接受其上的图/视频/PDF 也不会被爬

Part 7 — 控制内容 4 大方法决策表

来自 control-what-you-share。按从强到弱排序。

方法 适用 优点 缺点
1. 删掉内容 所有类型 100% 不会出现在 Google 或互联网任何地方 不可恢复
2. 密码保护 所有类型 真正的访问控制,Google 也搜不到 用户需要登录
3. noindex 所有类型 内容仍可被用户访问,但不进搜索结果 需要 Googlebot 爬到才生效;不防其他搜索引擎(其他可能不支持 noindex)
4. robots.txt Disallow 仅图/视频/音频有效(web 页只阻爬不阻索引) 简单 web 页没用,只控爬
5. Opt out 特定 Google 产品 只 web 页 细粒度(只屏蔽 Shopping/Hotels/vacation rentals 等) 只对 Google,不防别的引擎

7.1 何时该 block 内容?

  1. 数据保密 — 用户登录后才能看的数据(注意 file metadata 可能也泄露,看 keep-redacted-information-out)
  2. 低质内容(用户生成 spam)— 索引这些会拖累整站排名
  3. 大站 crawl budget 优化 — >数十万 URL 的站,让 Google 别浪费 crawl 在不重要 / 重复内容上

7.2 已索引内容如何移除

走 Remove information。Search Console Removals tool 可临时(~6 个月)从搜索结果撤,争取时间彻底处理。


Part 8 — 移除图片专项

8.1 紧急移除

Search Console Removals tool → 选 image URL。⚠️ 临时(默认 ~6 月),到期会回来。要永久 → 配 robots.txt 或 X-Robots-Tag noindex 兜底。

8.2 非紧急移除两种方式(选一即可)

A. robots.txt Disallow + Googlebot-Image UA

User-agent: Googlebot-Image
Disallow: /images/dogs.jpg

只移除 dogs.jpg 不影响其他图。

多张图:

User-agent: Googlebot-Image
Disallow: /images/dogs.jpg
Disallow: /images/cats.jpg
Disallow: /images/llamas.jpg

# 或用 wildcard
Disallow: /images/animal-picture-*.jpg

全站图全移除:

User-agent: Googlebot-Image
Disallow: /

某种格式全移除(例: 移除所有 .gif):

User-agent: Googlebot-Image
Disallow: /*.gif$

8.3 UA 选哪个?

UA 影响
Googlebot-Image 只从 Google Images 移除(web 搜索还会有)
Googlebot 全部 Google 搜索都移除

8.4 B. X-Robots-Tag: noindex HTTP header

适合 CDN 托图或没法改 robots.txt 的情况。前提:图必须能被 Googlebot 爬到(才能读到 header)。

8.5 noimageindex 的局限

页面级 <meta name="robots" content="noimageindex"> 阻止该页内嵌的图被索引,但同张图出现在别的页,仍会通过别的页被索引。

真正全局阻图被索引 → 用 image URL 上的 X-Robots-Tag: noindex。


Part 9 — User-Triggered Fetchers(9 个,忽略 robots.txt)

关键: 这些 fetcher 是用户主动操作触发的(不是 Google 自己爬),所以通常忽略 robots.txt。你 disallow 也没用。

9.1 完整列表

名字 UA token 用途
Chrome Web Store Google-CWS 抓 Chrome 扩展 metadata 里的 URL
Feedfetcher FeedFetcher-Google 抓 RSS/Atom feed,给 Google News + WebSub
Google-Agent ⭐ Google-Agent 给 Google AI agents 用(如 Project Mariner)。用 user-triggered-agents.json IP 范围。Google 还在试验 Web Bot Auth 用 https://agent.bot.goog 身份。
Google Messages GoogleMessages 生成聊天里 URL 的预览
Google NotebookLM Google-NotebookLM 用户在 NotebookLM 添加的 source URL
Google Pinpoint Google-Pinpoint 用户在 Pinpoint 加的文档 source
Google Publisher Center GoogleProducer publisher 主动给 Google News 的 feed
Google Read Aloud Google-Read-Aloud(原 google-speakr 已废) 用户请求 TTS 朗读
Google Site Verifier Google-Site-Verification/1.0 Search Console 所有权验证

9.2 反向 DNS 验证

  • Google 自有 fetcher: ***-***-***-***.gae.googleusercontent.com
  • 用户托管(GAE 用户站): google-proxy-***-***-***-***.google.com

9.3 ⚠️ UA 可被伪造

要确认请求真是 Google → 走 verify Google requests 反向 IP + 正向 DNS 验证。


Part 10 — 出站链接限定符 (rel attribute)

10.1 4 类 rel 值

rel 值 用途 示例
(不写) 正常链接,Google 正常 follow + 解析 <a href="...">x</a>
sponsored 广告 / 付费推广(paid link) <a rel="sponsored" href="...">
ugc 用户生成内容(评论 / 论坛) <a rel="ugc" href="...">
nofollow 其他不想关联或不想 follow 的链接 <a rel="nofollow" href="...">

10.2 关于 sponsored vs nofollow(2019 进化)

  • 2019 前: paid link 用 nofollow
  • 2019 后: 推荐 sponsored,但 nofollow 仍可接受
  • 不要漏标 — 不标 paid link 会触发 link spam policy

10.3 关于 ugc

  • 推荐给评论 / 论坛 / 留言板
  • 你可以选择性移除 rel="ugc" 给那些"长期高质量贡献者"的链接,作为奖励

10.4 多个 rel 值组合

空格或逗号都行:

<a rel="ugc nofollow" href="...">x</a>
<a rel="ugc,nofollow" href="...">x</a>

10.5 ⚠️ 关键点

  • 这些 rel 属性是 hint,Google 通常不 follow 这些链接,但:
    • 链接的页可能通过别的渠道被发现(sitemap / 其他外链)
    • 所以 rel="nofollow" 不防止页被索引
  • 想真正阻止 Google 爬你自己站某页 → 用 robots.txt 的 Disallow:,不要靠 nofollow
  • 想真正不让自己站某页被索引 → 用 noindex,不要靠 nofollow
  • rel="nofollow" 也可作为 robots meta tag 用(<meta name="robots" content="nofollow">),其他 rel 值不行

Part 11 — 实战决策树

11.1 我想隐私 / 安全保护数据

→ 密码保护(server-side auth)。robots.txt / noindex / nofollow 全不靠谱。

11.2 我有一个测试环境 / staging server

→ 整站密码保护(basic auth 都行)。 不要靠 robots.txt — 一旦上线忘改,Google 索引你 staging URL 一辈子洗不干净。

11.3 我想这张 PDF 不被搜到

→ HTTP server 配 X-Robots-Tag: noindex 对 .pdf 文件。robots.txt 没用(PDF 是文本类,被 disallow 仍可能因外链被索引)。

11.4 我想这张图不被搜到

→ robots.txt User-agent: Googlebot-Image Disallow: /... 或 该图 URL 上 X-Robots-Tag: noindex。选一即可。

11.5 我有 50 个评论里的链接想让 Google 不传 PageRank

→ 评论 link 加 rel="ugc"(或 rel="nofollow")。CMS 多数自动加。

11.6 我有 5 个广告位想合规标记

→ 广告 link 加 rel="sponsored"。

11.7 我有一篇文章马上要 paywall 了,想从搜索结果撤

→ <meta name="robots" content="unavailable_after: 2026-12-31T00:00:00+08:00">

11.8 我想这页的 description 别被截太短(rich result 用 schema description)

→ 不要用 max-snippet 限制,而是直接编辑 article.description schema 字段。


Part 12 — 反 pattern 集锦

# 反 pattern 后果
1 robots.txt Disallow 一个页 + 期望它不被索引 还是会出现在结果(无 description)
2 robots.txt Disallow + 加 noindex noindex 永远看不到,互相残杀
3 robots.txt 写 Noindex: /xxx Google 不支持这条,完全无效
4 robots.txt block 重要 JS/CSS 渲染失败,索引质量降低
5 用 noarchive / nocache / nositelinkssearchbox 已废弃,Google 完全忽略
6 JS 动态加/删 data-nosnippet 渲染前抽取那次会看到不一致的状态,行为不可预测
7 data-nosnippet 用在 <custom-tag> 无效,只支持 span/div/section
8 期望 robots.txt 防止恶意爬虫 它不是安全机制,守规矩的才听
9 期望 nofollow 完全阻止页被索引 nofollow 只是 hint,页仍可被发现
10 付费链接不标 rel="sponsored" 或 nofollow 违反 link spam policy,可能被处罚
11 通过 robots.txt Block noimageindex 想让图不被索引 noimageindex 是页面级,放在 page 上而不是 image URL 上,且只防该页内嵌的图
12 用 <meta name="ai-bot" content="noindex"> 想防 AI 爬 Google 不识别 ai-bot 这种自定义 UA token;只识别 robots / googlebot / googlebot-news
13 meta robots 不放 <head> 期望失效来"试探" Google 不强制 head/body 位置,还是会读到,不能用错位置当后悔药

Part 13 — 相关 wiki

Last updated

2026-05-17 — 基于 Google Search Central 7 篇 robots/control 系列(2025-12 ~ 2026-05 最新)整理。包含 2026-03 robots-meta-tag 更新(含 AI Overviews / AI Mode 与 nosnippet 关系)和 2026-05 user-triggered fetchers 加入 Google-Agent (Project Mariner) + Web Bot Auth。

来源与关联资料