robots.txt 中有关不受支持规则的注意事项
2019 年 7 月 2 日,星期二
昨天,我们宣布了将 Google 的生产 robots.txt 解析器开源。这是一个激动人心的时刻,让我们为将来可能发布的开源项目铺平了道路!反馈很有帮助,我们热切希望从开发者和网站站长那里收集问题。有一个问题很突出,我们将在这篇博文中予以解决:
为什么代码中未包含其他规则(例如抓取延迟)的代码处理程序?
我们昨天发布的互联网草案为未纳入标准中的规则提供了可扩展架构。这意味着,如果抓取工具希望支持自己的代码行(如 unicorns: allowed
),就可以做到。为了演示在解析器中是什么样的,我们在开源 robots.txt 解析器中加入了一个非常常见的代码行“站点地图”。
在将解析器库开源的过程中,我们分析了 robots.txt 规则的使用。具体而言,我们侧重于互联网草稿不支持的规则,例如 crawl-delay
、nofollow
和 noindex
。由于这些规则从未由 Google 记录,因此在 Googlebot 中的使用频率非常低。再深入挖掘,我们发现,在互联网上的所有 robots.txt 文件中,只有 0.001% 不存在这些规则的用法与其他规则相悖的情况。此类错误会影响网站在 Google 搜索结果中的显示效果,我们认为这不符合网站站长的预期。
为了维护健康的生态系统并准备未来可能发布的开源版本,我们将于 2019 年 9 月 1 日弃用所有用于处理不受支持且未发布的规则(例如 noindex
)的代码。对于依赖于 robots.txt
文件(用于控制抓取)中的 noindex
索引编制规则的用户,我们还提供了一些备选方案:
- robots
meta
标记中的 noindex
:HTTP 响应标头和 HTML 均支持 noindex
规则,此类规则是在允许抓取时从索引中移除网址的最有效方法。
-
404
和 410
HTTP 状态代码:这两种状态代码都表示该网页不存在,这会在此类网址抓取和处理完毕后将其从 Google 索引中移除。
-
密码保护:除非标记用于表示订阅或付费内容,否则为网页设置登录限制通常会将网页从 Google 索引中移除。
-
robots.txt
中的 Disallow
:搜索引擎只能将已知的网页编入索引,因此阻止抓取相应网页通常意味着系统不会将其内容编入索引。虽然搜索引擎也可以根据其他网页中的链接将网址编入索引,而不查看内容本身,但我们的目标是在将来降低此类网页的曝光度。
-
Search Console“移除网址”工具:该工具可让您快速轻松地从 Google 搜索结果中暂时移除网址。
如需有关如何从 Google 搜索结果中移除信息的更多指导,请访问我们的帮助中心。如有任何疑问,可以通过 Twitter 和网站站长社区(离线和在线)联系我们。
发布者:Gary Illyes
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
[null,null,[],[[["Google open-sourced their robots.txt parser and is retiring support for undocumented and unpublished rules (like `noindex`) on September 1, 2019."],["Unsupported rules like `crawl-delay`, `nofollow`, and `noindex` were never documented by Google and their usage is contradicted by other rules in almost all robots.txt files."],["Webmasters relying on the `noindex` directive in robots.txt should switch to alternatives like `noindex` in robots meta tags, `404/410` status codes, or password protection."],["Google provides alternative options for removing URLs from search results, including disallowing crawling in robots.txt and using the Search Console Remove URL tool."],["Developers and webmasters can provide feedback and ask questions through GitHub, Twitter, and the Webmaster Community."]]],["Google open-sourced its robots.txt parser, allowing for custom rules like \"unicorns: allowed.\" The parser will retire code handling unsupported rules like `noindex` on September 1, 2019. Alternatives to `noindex` in robots.txt include `noindex` in meta tags, 404/410 HTTP status codes, password protection, `Disallow` in robots.txt, and the Search Console Remove URL tool. Google analyzed robots.txt rule usage and found unsupported rules are rarely used effectively.\n"]]