MediaWikiでサイトマップを作成する

MediaWikiにはサイトマップ生成ツールが付属しています。 cronで定期的に生成しておくのが良いですね。

このサイトでは下記のようなコマンドで生成しています。

/usr/bin/php /path-to-mediawiki/maintenance/generateSitemap.php \
--compress=no \
--fspath /path-to-mediawiki/sitemap/ \
--server='http://www.dondari.com' \
--identifier=wiki \
--urlpath='http://www.dondari.com/sitemap'

出来上がり

生成されたファイル

$ ls -l /path-to-mediawiki/sitemap/
sitemap-index-wiki.xml
sitemap-wiki-NS_0-0.xml
sitemap-wiki-NS_14-0.xml
sitemap-wiki-NS_274-0.xml
sitemap-wiki-NS_6-0.xml
sitemap-wiki-NS_8-0.xml

indexファイルの内容

$ cat sitemap/sitemap-index-wiki.xml
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <sitemap>
                <loc>http://www.dondari.com/sitemap/sitemap-wiki-NS_0-0.xml</loc>
                <lastmod>2013-09-27T12:43:20Z</lastmod>
        </sitemap>
        <sitemap>
                <loc>http://www.dondari.com/sitemap/sitemap-wiki-NS_6-0.xml</loc>
                <lastmod>2013-09-27T12:43:20Z</lastmod>
        </sitemap>
        <sitemap>
                <loc>http://www.dondari.com/sitemap/sitemap-wiki-NS_8-0.xml</loc>
                <lastmod>2013-09-27T12:43:20Z</lastmod>
        </sitemap>
        <sitemap>
                <loc>http://www.dondari.com/sitemap/sitemap-wiki-NS_14-0.xml</loc>
                <lastmod>2013-09-27T12:43:20Z</lastmod>
        </sitemap>
        <sitemap>
                <loc>http://www.dondari.com/sitemap/sitemap-wiki-NS_274-0.xml</loc>
                <lastmod>2013-09-27T12:43:20Z</lastmod>
        </sitemap>
</sitemapindex>

個別ファイルの内容

$ cat sitemap/sitemap-wiki-NS_0-0.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <url>
                <loc>http://www.dondari.com/.vimrc%E3%83%A1%E3%83%A2</loc>
                <lastmod>2013-04-20T14:00:12Z</lastmod>
                <priority>1.0</priority>
        </url>
        <url>
                <loc>http://www.dondari.com/500_Internal_Server_Error%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%AE%E9%85%8D%E7%BD%AE</loc>
                <lastmod>2013-04-20T13:49:47Z</lastmod>
                <priority>1.0</priority>
        </url>
        <url>
                <loc>http://www.dondari.com/@var%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%81%A7%E5%A4%89%E6%95%B0%E3%81%AE%E5%9E%8B%E3%82%92%E6%98%8E%E8%A8%98%E3%81%99%E3%82%8B</loc>
                <lastmod>2013-04-20T13:47:29Z</lastmod>
(..snip..)
                <loc>http://www.dondari.com/%E8%AA%AD%E3%81%BF%E5%8F%96%E3%82%8A%E5%B0%82%E7%94%A8%E3%81%A7%E9%96%8B%E3%81%8FExcel</loc>
                <lastmod>2011-06-10T06:44:19Z</lastmod>
                <priority>1.0</priority>
        </url>
        <url>
                <loc>http://www.dondari.com/%E9%85%8D%E5%88%97%E3%82%92%E3%83%9E%E3%83%83%E3%83%81%E3%83%B3%E3%82%B0</loc>
                <lastmod>2013-04-20T13:42:46Z</lastmod>
                <priority>1.0</priority>
        </url>
        <url>
                <loc>http://www.dondari.com/%E9%8D%B5%E4%BA%A4%E6%8F%9B%E6%96%B9%E5%BC%8F%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%9F%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E6%96%B9%E6%B3%95</loc>
                <lastmod>2011-08-19T07:15:27Z</lastmod>
                <priority>1.0</priority>
        </url>
</urlset>

googleウェブマスターツールに送信する

googleウェブマスターツール

facebook slideshare rubygems github qiita