Noindex 检查工具:检查任意网址是否带有 noindex 标签
简短回答 noindex 规则可能藏在两个地方:页面代码里的 robots meta 标签,或服务器发送的 X-Robots-Tag 响应头。两个都要查。查看页面源代码并搜索“noindex”,再用浏览器或 curl 查看响应头。对于您自己网站上的页面,Google 的网址检查工具(URL Inspection)会准确显示 Googlebot 看到了什么。
想把这些用到您的生意上?预约一次 30 分钟的免费通话,一起聊聊。
预约通话如何检查页面是否带有 noindex?
要查两个地方,因为 Google 两个都会读。Google 搜索中心(Search Central)的文档列出了设置 noindex 的两种方式。
一种是页面代码里的 meta 标签,另一种是 HTTP 响应头:
"They have the same effect; choose the method that is more convenient for your site and appropriate for the content type." (Google Search Central: Block Search indexing with noindex) 译文:“两者效果相同;请选择对您的网站更方便、也更适合该内容类型的方法。”
只读取页面代码的检查工具会漏掉响应头,所以两个都要查。
| 藏在哪里 | 长什么样 | 怎么查看 |
|---|---|---|
| robots meta 标签,在页面的 HTML 代码里 | `meta name="robots" content="noindex"` | 查看页面源代码,搜索“noindex” |
| 只针对 Google 的 meta 标签 | `meta name="googlebot" content="noindex"` | 同样搜索 |
| X-Robots-Tag HTTP 响应头(服务器随文件一起发送的说明,页面上看不到) | `X-Robots-Tag: noindex` | 浏览器开发者工具或 curl |
| 任一位置写的“none” | `content="none"` | Google 视为“noindex, nofollow” |
Google 的 robots meta 标签规范说明这些词不区分大小写,所以“NOINDEX”也算。规范还说,放在页面 body 里(而不只是 head 里)的 robots meta 标签,Google 也会遵守,所以要搜索整个源代码。
在浏览器里手动检查一个网址
- 打开页面。右键点击,选择 View Page Source(查看网页源代码),或在 Chrome 中在网址前加上 `view-source:`。
- 按 Ctrl+F(Mac 上是 Cmd+F),搜索 noindex,再搜索 none。只要在名为 `robots` 或 `googlebot` 的 meta 标签里找到匹配,就说明该页面要求不被编入索引。
- 查看响应头:打开 Chrome 开发者工具(F12),进入 Network(网络)标签页并刷新。点击第一行(页面本身),打开 Headers(标头),滚动到 Response Headers(响应标头)。Chrome DevTools 指南描述的正是这个路径。找名为 x-robots-tag 的一行。
PDF 也用这个方法查。PDF 没有 HTML 代码,所以响应头是唯一能放 noindex 的地方。Google 表示该响应头“can be used for non-HTML resources, such as PDFs, video files, and image files”(可用于非 HTML 资源,例如 PDF、视频文件和图片文件)(Google Search Central: Block Search indexing with noindex)。
用一条命令检查
如果您会用终端,curl 可以同时回答这两个问题。curl 手册对 `-I` 的描述是:“Fetch the headers only.”(只获取响应头。)
- 响应头:`curl -sIL https://yourdomain.com/page/ | grep -i x-robots-tag`
- meta 标签:`curl -sL https://yourdomain.com/page/ | grep -i noindex`
`-L` 会跟随重定向到最终页面。两条命令都没有输出,说明服务器发送的代码里没有 noindex。第二条命令有匹配时值得看一眼:这个词可能出现在页面文字里,而不是标签里。要检查一批网址,把每个网址单独一行存进 urls.txt,然后运行:`cat urls.txt | while read u; do echo "$u"; curl -sIL "$u" | grep -i x-robots-tag; curl -sL "$u" | grep -i noindex; done`
检查 Google 实际看到了什么
对于您自己网站上的页面,Search Console 说了算。它是免费的:“Google Search Console is a free service offered by Google”(Google Search Console 是 Google 提供的免费服务)(Search Console Help: About Search Console)。Google 的 noindex 页面推荐了它的两个工具:
"To test if your noindex implementation is correct, use the URL Inspection tool to see the HTML that Googlebot received while crawling the page. You can also use the Page Indexing report in Search Console to monitor the pages on your site from which Googlebot extracted a noindex rule." (Google Search Central: Block Search indexing with noindex) 译文:“要测试您的 noindex 设置是否正确,请使用网址检查工具查看 Googlebot 抓取页面时收到的 HTML。您还可以使用 Search Console 中的网页索引编制报告,监控您网站上哪些页面被 Googlebot 读取到了 noindex 规则。”
在网址检查工具中,看 Indexing allowed?(是否允许编入索引?)这一行。如果您希望被找到的页面显示“No”,就说明有 noindex 在阻止它(Search Console Help: URL Inspection tool)。要看全站列表,打开网页索引编制(Page indexing)报告,找与 noindex 标签有关的原因。各个原因的含义见:已抓取或已发现,但尚未编入索引。
免费的在线 noindex 检查工具会漏掉什么?
快速检查工具用来抽查没问题。但要了解它的盲点:
| 盲点 | 为什么重要 |
|---|---|
| 不检查响应头 | 有些工具只读 HTML;服务器或插件在响应头里设置的规则会被漏掉 |
| 由 JavaScript 添加的标签 | Google 的 JavaScript 指南展示了在页面加载后添加 robots meta 标签的代码。只读原始代码的工具会漏掉它 |
| 用 JavaScript 移除 noindex | Google 表示,遇到 noindex 时它“may skip rendering and JavaScript execution”(可能跳过渲染和 JavaScript 执行),所以用代码移除标签“may not work as expected”(可能达不到预期效果)(Google Search Central: JavaScript SEO basics)。noindex 必须从原始代码中删除 |
| robots.txt 屏蔽了该页面 | Google 无法读取它不能抓取的页面上的 noindex,所以该规则“will therefore be ignored”(因此会被忽略)(Google Search Central: Robots meta tag specifications)。检查工具显示有标签,但 Google 根本看不到 |
| 其他搜索引擎 | Google 提醒“some search engines might interpret the noindex rule differently”(有些搜索引擎对 noindex 规则的理解可能不同)(Google Search Central: Block Search indexing with noindex) |
robots.txt 这种情况在网址检查工具里有个反转:当 robots.txt 屏蔽了页面时,“Indexing allowed?”总是显示 Yes,因为 Google 看不到这个标签(Search Console Help: URL Inspection tool)。
发现了不想要的 noindex?
- 找到来源。 在 WordPress 上,查看“设置”下的“阅读”。勾选“Discourage search engines from indexing this site”(建议搜索引擎不索引本站点)会给每个页面加上 noindex, nofollow 标签(WordPress Documentation: Settings Reading Screen)。网站改版后常常忘了取消勾选。否则就查看您的 SEO 插件的单页设置、网站主题,或主机商的响应头规则。
- 从原始代码中删除它,而不是用之后才运行的脚本删除(见上表中 JavaScript 那一行)。
- 确保 robots.txt 没有屏蔽该页面。 Google 必须抓取页面才能发现改动。
- 用网址检查工具请求 Google 重新抓取。 Google 表示,不这样做的话,“it may take months for Googlebot to revisit a page”(Googlebot 可能要过几个月才会再次访问页面)(Google Search Central: Block Search indexing with noindex)。
为了节省 Google 的抓取时间而添加 noindex 也没用。Google 说“Don't use noindex”(不要使用 noindex),因为它仍会请求该页面,然后再丢弃,“wasting crawling time”(浪费抓取时间)(Google Crawling Infrastructure: Optimize your crawl budget)。而且这条建议本来就是针对超大型网站的。
示例
以下为说明性案例。
一家屋顶公司的新 WordPress 网站
网站上线两个月后,服务页面一直没有出现在 Google 上。查看首页源代码,发现 `content='noindex, nofollow'`。开发人员没有取消勾选“Discourage search engines”。取消勾选,再在网址检查工具中为五个主要页面请求编入索引,就解决了。
一位会计师的价目表 PDF
这个 PDF 有排名,但价格变了,老板想把它从 Google 上撤下。它的 HTML 放不了 meta 标签,所以主机商为这个文件加上了 `X-Robots-Tag: noindex`。对 PDF 的网址运行 `curl -sI`,确认该响应头已发送。
一家诊所用 JavaScript 搭建的预约页面
一个在线检查工具显示“可编入索引”,但网址检查工具显示不允许编入索引。页面的初始代码带有 noindex,加载后由脚本删除。Google 按原始代码处理了。从模板中删除该标签就解决了。
常见问题
noindex 检查工具和检查页面是否已编入索引是一回事吗?
不是。noindex 检查工具告诉您页面是否要求不被编入索引。没有 noindex 的页面仍可能因为其他原因不在 Google 上。网址检查工具会显示实际的索引状态。
nofollow 会阻止页面被编入索引吗?
不会。nofollow 告诉 Google 不要跟踪页面上的链接。noindex 会让页面不出现在搜索结果中,“none”也一样,Google 把它视为 noindex 加 nofollow(Google Search Central: Robots meta tag specifications)。
可以把 noindex 写在 robots.txt 里吗?
不可以。Google 表示“Specifying the noindex rule in the robots.txt file is not supported by Google”(Google 不支持在 robots.txt 文件中指定 noindex 规则)(Google Search Central: Block Search indexing with noindex)。
删除 noindex 后,页面多久会回来?
要等 Google 再次抓取之后。在网址检查工具中请求重新抓取;Google 表示,不请求的话,再次访问可能需要几个月。
您的情况不同?
- 页面没有 noindex,但仍然不在 Google 上:网站在 Google 上搜不到。
- Search Console 显示页面未编入索引:已抓取或已发现,但尚未编入索引。
- 您还没有设置 Search Console:小企业如何使用 Google Search Console。
- 您想尽快让某个页面从 Google 上消失:从 Google 移除信息。
- 您的建站平台让代码很难修改:Wix 或 Squarespace 对 SEO 不好吗?
- 您希望有人替您检查索引情况:SEO 与 GEO 智能体。