検索エンジン最適化を図るための、WordPressの「robots.txt」と「metaタグ」の紹介です。
robots.txtとmetaタグの内容は、下記サイトを参考にし、当サイトおよび日本サイト向けに変更しました。
もし使用する場合は、当サイト独自の箇所は、使用するサイトに合わせて修正してご利用ください。
WordPress robots.txt SEO
[ASKAPACHE]
SEO用のrobots.txt
WordPressを設置しているルート フォルダの「robots.txt」に下記を記述します。
※参照サイトでアップデートがあったので、2007-10-18に追加:オレンジ箇所、削除:打ち消し線で修正しました。
User-agent: * Disallow: /cgi-bin Disallow: /wp-admin Disallow: /wp-includes Disallow: /wp-content/plugins Disallow: /wp-content/cache Disallow: /wp-content/themes Disallow: /trackbackDisallow: /feedDisallow: /comments Disallow: /tagDisallow: /articles/categoryDisallow: /articles/category/* Disallow: */trackbackDisallow: */feedDisallow: */comments Disallow: /*?* Disallow: /*? Allow: /wp-content/uploads # Google Image User-agent: Googlebot-Image Disallow: Allow: /* # Google AdSense User-agent: Mediapartners-Google* Disallow: Allow: /* # Internet Archiver Wayback Machine User-agent: ia_archiver Disallow: / # digg mirror User-agent: duggmirror Disallow: / Sitemap: http://coliss.com/sitemap.xml
「Disallow: /tag」「Disallow: /articles/category/*」は、当サイトでオリジナルのフォルダ名になっています。
「Sitemap: http://coliss.com/sitemap.xml」は、サイトマップファイルの指定になっています。
SEO用のmetaタグ
下記のテキストをheader.phpの「<?php wp_head(); ?>」の上などに挿入します。
<?php if(is_single() || is_page() || is_category() || is_home()) { ?>
<meta name="robots" content="all,noodp,noydir" />
<?php } ?>
<?php if(is_archive()) { ?>
<meta name="robots" content="noarchive,noodp,noydir" />
<?php } ?>
<?php if(is_search() || is_404()) { ?>
<meta name="robots" content="noindex,noarchive" />
<?php } ?>
NOODP、NOYDIRについては、下記を参照ください。
Yahoo! やGoogleの検索結果の説明文を変更する方法|コリス
Post on:2007年8月29日


