robots.txt 加 noindex:让网页一直留在 Google 里的错误
简短回答 不要在同一个网页上同时使用两者。Google 必须抓取网页才能读到 noindex 标签,而 robots.txt 屏蔽会阻止抓取,所以 Google 永远看不到这个标签。网址可能继续留在搜索结果中,往往没有描述。要移除网页:删除 robots.txt 规则,保留 noindex,让 Google 重新抓取。
想把这些用到您的生意上?预约一次 30 分钟的免费通话,一起聊聊。
预约通话为什么 robots.txt 加 noindex 会让网页留在 Google 里
这两条规则会互相抵消。robots.txt 是放在网站根目录的一个文件,告诉搜索引擎机器人可以访问哪些地址。noindex 是写在某个网页里(或写在服务器对该网页的响应中)的一行指令,意思是“不要把我列入搜索结果”。要读到 noindex,Google 必须访问这个网页。访问被屏蔽,noindex 就永远读不到。Google 说得很直接:
"If the page is blocked by a robots.txt file or the crawler can't access the page, the crawler will never see the noindex rule, and the page can still appear in search results, for example if other pages link to it." (Google Search Central: Block Search indexing with noindex) 译文:“如果网页被 robots.txt 文件屏蔽,或者抓取工具无法访问该网页,抓取工具就永远看不到 noindex 规则,网页仍可能出现在搜索结果中,例如有其他网页链接到它时。”
这条规则适用于所有索引指令,不只是 noindex:“If indexing or serving rules must be followed, the URLs containing those rules cannot be disallowed from crawling”(如果必须遵守索引或展示规则,就不能禁止抓取包含这些规则的网址)(Google Search Central:Robots meta 标签规范)。
在 robots.txt 里屏蔽网页,不就能把它从 Google 移除吗?
不能。robots.txt 控制的是访问,不是收录。Google 称它“not a mechanism for keeping a web page out of Google”(不是让网页不出现在 Google 中的机制)(Google Search Central:robots.txt 简介)。如果其他网页链接到一个被屏蔽的地址,Google 不用打开它也能把它列出来。您在搜索中看到的会是:只有一个地址,下面没有任何描述(同一页面)。
我该用哪一个?
| 目标 | 使用 | 原因 |
|---|---|---|
| 不让网页出现在搜索结果中 | 只用 noindex | Google 必须抓取网页才能遵守它 |
| 不让任何人看到私密内容 | 密码或登录 | Google 把密码保护列为一种移除方法(Google Search Central) |
| 不让机器人访问浪费抓取时间或增加服务器负担的网页 | 只用 robots.txt | 这是它的主要用途(Google Search Central) |
| 不让图片、视频或音频出现在 Google 中 | robots.txt | Google 说这对媒体文件有效(同一页面) |
| 今天就移除一个网页 | 先用 Search Console 的“移除”工具,再加 noindex | 该工具会“within a day”(在一天内)隐藏网页;noindex 让它永久生效(Google Search Central) |
还有一个陷阱:把 `noindex` 写在 robots.txt 里。“Specifying the noindex rule in the robots.txt file is not supported by Google”(Google 不支持在 robots.txt 文件中指定 noindex 规则)(Google Search Central)。
修复步骤,按顺序来
- 删除屏蔽该网页的 robots.txt 规则。 在 Wix、Blogger 等建站工具上,您可能无法直接编辑这个文件;请改为查找搜索设置页面(Google Search Central)。
- 保留网页上的 noindex:在网页的 head 部分加一个设为 `noindex` 的 robots meta 标签,或使用 `X-Robots-Tag: noindex` 响应头。Google 说两者“have the same effect”(效果相同)(Google Search Central)。
- 检查 Google 看到了什么。 在 Search Console 中对该网页运行网址检查;Google 建议用它查看“the HTML that Googlebot received”(Googlebot 收到的 HTML)(同一页面)。
- 在网址检查中请求重新抓取。 不这样做的话,Google 说对于很少有网站链接的网页,再次访问“may take months”(可能需要几个月)(同一页面)。
- 等待网页掉出搜索结果。 一旦 Google 读到这个标签,就会移除网页,“regardless of whether other sites link to it”(无论其他网站是否链接到它)(同一页面)。
- 只有在必要时才重新加回 robots.txt 屏蔽,而且要等网页已经离开搜索结果之后。从那以后 Google 会忽略 noindex,所以如果有新链接指向它,网页可能会重新出现。
Search Console 会显示什么
“网页索引编制”报告会直接点出这个问题。已编入索引,尽管遭到 robots.txt 屏蔽(Indexed, though blocked by robots.txt)表示 Google 没有访问网页就把它收录了。它的建议是:
"To avoid being indexed, remove the robots.txt block and use 'noindex'." (Search Console Help: Page indexing report) 译文:“要避免被编入索引,请移除 robots.txt 屏蔽并使用‘noindex’。”
网址被标记为“noindex”(URL marked 'noindex')是您刻意隐藏的网页应有的状态。其他每种状态的含义,请看我们的网页索引状态指南。
示例
一个删不掉的感谢页
一家清洁公司给“感谢预约”页面加了 noindex,为保险起见又在 robots.txt 里屏蔽了它。几个月后,这个页面仍然出现在 Google 中,没有任何描述。他们删除了 robots.txt 中的那一行,请求重新抓取,Google 再次访问后页面就消失了。
一份旧价目表
一家诊所 2024 年的价目表一直被 robots.txt 屏蔽。Search Console 显示“已编入索引,尽管遭到 robots.txt 屏蔽”。解决办法是移除屏蔽并加上 noindex;在等待期间,用“移除”工具可在一天内先把它隐藏起来。
常见问题
Google 能收录一个从未抓取过的网页吗?
能。如果其他网页链接到这个地址,Google 仅凭这些链接就能把它列出来,通常几乎没有描述或完全没有描述(Search Console 帮助)。
我还要加 nofollow 吗?
只有在您希望 Google 也忽略网页上的链接时才需要。`noindex, nofollow` 可以一起使用(Google Search Central)。它不影响网页是否被收录。
加了 noindex 的网页要多久才会消失?
要等 Google 下次抓取它之后。对于很少被链接的网页,这可能需要几个月,所以请在网址检查中请求重新抓取(Google Search Central)。
其他搜索引擎会遵守 noindex 吗?
Google 提到,“that don't support noindex”(不支持 noindex)的搜索引擎仍可能显示该网页(Google Search Central)。真正私密的内容,请用密码保护。
您的情况不同?
- 不确定网页到底有没有被收录? 先从 Search Console 基础开始。
- 要屏蔽的是 AI 机器人,不是 Google 搜索? 那是 robots.txt 的另一种选择,有不同的取舍:屏蔽 AI 抓取工具。
- 新网站上线后排名下降? 检查是否有测试网站遗留的 robots.txt 屏蔽:改版后流量下降。
- 想找人审核抓取和索引设置? 请看 SEO 与 GEO 智能体。