問題描述

什麼是 robots.txt 的”best” 設置?我正在使用以下永久鏈接結構/%category%/%postname%/

我的 robots.txt 目前看起來像這樣 (從很久以前的某個地方複製):

User-agent: *
Disallow: /cgi-bin
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content/plugins
Disallow: /wp-content/cache
Disallow: /wp-content/themes
Disallow: /trackback
Disallow: /comments
Disallow: /category/*/*
Disallow: */trackback
Disallow: */comments
  1. 我希望我的意見被索引。所以我可以刪除這個

  2. 由於我的永久鏈接結構,我是否想禁止索引類別?

  3. 文章可以包含多個標籤,並且有多個類別。這可能會導致像 Google 這樣的搜索提供商重複。我應該如何解決這個問題?

你會改變別的嗎

最佳解決辦法

FWIW,回溯 URL 問題重定向並且沒有內容,所以他們不會被索引。

並且有沒有回答這個問題的風險,RE 你的觀點 2 和 3:

http://googlewebmastercentral.blogspot.com/2008/09/demystifying-duplicate-content-penalty.html

否則,我認為你正在浪費你的時間擔心 dup 內容,而您的 robots.txt 應該限於:

User-agent: *
Disallow: /cgi-bin
Disallow: /wp-admin
Disallow: /wp-content/cache

次佳解決辦法

自從這個問題以來,很多時間都被髮布。此後事情發生了很大變化。關於禁止抓取程序訪問 wp-content/themeswp-content/pluginswp-content/cachewp-includes 以及包含站點所需的 CSS 或 js 文件的任何其他目錄的典型建議不再有效。

例如,讓我們來談談 Google 。 Googlebot 正在呈現沒有 CSS 而沒有 js 的網站,但實際上並沒有。實際上,Googlebot 會提供完整的文檔,並檢查腳本的響應性,數量,位置和大小等等。所以 Google 不喜歡,如果您不允許 Googlebot 訪問 CSS 和 js 文件。這意味着您不應該禁止 wp-content/themeswp-content/pluginswp-content/cachewp-includes,因為所有這些文件夾都可以提供 CSS 和 js 文件。

從我的角度來看,實際上最好的 robots.txt 文件是由 WordPress 默認創建的文件 (the bellow robots.txt is the default since WP 4.0):

User-agent: *
Disallow: /wp-admin/

如果您有一個 cgi-bin 文件夾,最好不要使用 cgi-bin 文件夾:

User-agent: *
Disallow: /wp-admin/
Disallow: /cgi-bin/

如果您使用站點 Map,最好在 robots.txt 中添加一個站點 Map 引用 (您仍然需要手動將站點 Map 提交給 Google 和 Bing 網站管理員工具,但該參考對其他抓取工具來説可能會有用):

User-agent: *
Disallow: /wp-admin/
Disallow: /cgi-bin/

Sitemap: http://example.com/sitemap.xml

一般來説具體的網站可能不允許在每個具體情況下應該研究的其他文件夾和文件。對於例外,您可能需要,或者您可能不想使用特定的插件文件夾:

User-agent: *
Disallow: /wp-admin/
Disallow: /wp-content/plugins/plugin-folder/

要修改 robots.txt,請使用 robots_txt 過濾器 (使用真實的 robots.txt 文件將使 WordPress 不再能夠處理 robots.txt) 。例如:

add_filter( 'robots_txt', function( $output ) {

    $output .= "Disallow: /cgi-bin/n";
    $output .= "Disallow: /wp-content/plugins/plugin-folder-i-want-to-block/n";
    $output .= "nSitemap: " . site_url( 'sitemap.xml' ) . "n";

    return $output;

});

第三種解決辦法

你看過 Yoast 的 WordPress SEO plugin 嗎?它肯定處理 robots.txt 問題。

第四種辦法

有一點幫助,這是現在的礦山 (沒有太多的不同,每個人,顯然)

User-agent: *
    Allow: /

Disallow: /wp-content/
    Disallow: /wp-admin/
    Disallow: /cat/
    Disallow: /key/
    Disallow: /*?
    Disallow: /*.js$
    Disallow: /*.inc$
    Disallow: /*.css$
    Disallow: /cgi-bin
    Disallow: /wp-admin
    Disallow: /wp-includes
    Disallow: /wp-content/plugins
    Disallow: /wp-content/cache
    Disallow: /wp-content/themes

User-agent: Mediapartners-Google
    Allow: /

User-agent: Adsbot-Google
    Allow: /

User-agent: Googlebot-Image
    Allow: /

User-agent: Googlebot-Mobile
    Allow: /

#User-agent: ia_archiver-web.archive.org
    #Disallow: /

Sitemap: YOURSITENAME.HERE

參考文獻

注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。