robots.txt 不支援規則的注意事項
2019 年 7 月 2 日,星期二
昨天我們宣布了,要為 Google 生產 robots.txt 剖析器採用開放原始碼。這是令人振奮的時刻,這樣做等於是為將來的 Google 搜尋開放原始碼專案鋪路!我們非常重視您的寶貴意見,同時也致力於向開發人員和網站管理員收集問題。我們會在本文中回答以下問題:
為什麼程式碼中沒有檢索延遲等其他規則的程式碼處理常式?
我們昨天發布的網際網路草稿,為非標準規則提供了可擴充的架構。這表示,檢索器可以設定支援自己的指令行,像是 unicorns: allowed
。為了展示在剖析器中呈現的效果,我們在開放原始碼 robots.txt 剖析器中加入了十分常用的指令行 Sitemap。
在為剖析器程式庫採用開放原始碼時,我們分析了 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
:搜尋引擎只能對已知的網頁建立索引,因此禁止 Google 檢索網頁,通常就意味著網頁內容不會編入索引。此外,即使無法查看網頁內容,搜尋引擎也可能根據其他網頁的連結將網址編入索引,但我們打算設法降低這類網頁日後的能見度。
-
Search Console 的移除網址工具:這項工具可讓您快速輕鬆地從 Google 搜尋結果中暫時移除網址。
如要進一步瞭解如何從 Google 搜尋結果中移除資訊,請前往說明中心。如有任何疑問,歡迎前往 Twitter 以及網站管理員社群與我們聯絡,離線和線上皆可使用。
發文者:Gary Illyes
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。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"]]