プログラミング言語や環境設定を中心としたパソコン関連の技術メモです。
主にシステム開発中に調べたことをメモしています。TIPS的な位置付けで、気が向いたときにちまちま更新していきます。
複数のsitemap.xmlを設置する
結論から書くと

■やり方その1
(1)複数のsitemap.xmlを設置する
(2)設置した複数のsitemap.xmlの場所をrobots.txtに記述する

■やり方その2
(1)複数のsitemap.xmlを設置する
(2)sitemap.xmlのsitemap.xml(sitemap_index.xml)を設置する
(3)sitemap_index.xmlの場所をrobots.txtに記述する

の2つのやり方があるようです。

それでは詳細を書いていきます。

「やり方その1」は単純ですね。

例えば「sitemap.xml」と「sitemap2.xml」を
「http://example.com」直下に置いたとしましょう。

robots.txtには

User-agent: *
Sitemap: http://example.com/sitemap.xml
Sitemap: http://example.com/sitemap2.xml

と書きます。

これだけです。

「やり方その2」は少しだけ手順が増えます。

例えば「sitemap.xml」と「sitemap2.xml」を
「http://example.com」直下に置いたとしましょう。

sitemap.xmlのsitemap.xmlを設置します。
今回は「sitemap_index.xml」という名前にしますね。

「sitemap_index.xml」の中にはsitemap.xmlを記述します。
例えば、以下のような内容です。

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://example.com/sitemap.xml</loc>
</sitemap>
<sitemap>
<loc>http://example.com/sitemap2.xml</loc>
</sitemap>
</sitemapindex>

基本的にはsitemap.xmlと同じ書き方ですが「sitemapindex」タグで囲んでいるのと
「url」タグが「sitemap」タグになっているのが特徴です。

あとは「sitemap_index.xml」の場所をrobots.txtに記述します。

User-agent: *
Sitemap: http://example.com/sitemap_index.xml

のような内容になります。

これで終わりです。

個人的には「やり方その1」でも良いと思うのですが、
一般的には「やり方その2」が推奨されているっぽいです。

「どちらでもOK!」な人は「やり方その2」にしておいた方が無難なのではないでしょうか。

とりあえず、そんな感じ\(--)/
スポンサーリンク
 
このエントリーをはてなブックマークに追加 

category:● その他  thema:パソコンな日々 - genre:コンピュータ  Posted by ササキマコト 

  関連記事