From SpectLog
Jump to: navigation, search

Follow these steps to generate and expose your sitemap to the web.

Two simple steps

Change to the base directory of the WikiMedia installation and check whether the script for manual sitemap generation works:

php ./maintenance/generateSitemap.php --help


Generate the sitemap:

php ./maintenance/generateSitemap.php \
--fspath sitemap \
--identifier example \
--server http://example.com \
--urlpath http://example.com/wiki/maintenance/sitemap


The sitemap will be accessible using this URL:

http://example.com/wiki/maintenance/sitemap/sitemap-index-example.xml

Access restrictions for sitemap file

The command generates sitemap under ./maintenance/sitemap directory which can have restricted access. Instead of moving the directory somewhere else, when Apache HTTP server is used, .htaccess file with the following content can be placed into ./maintenance/sitemap directory:

Allow from all

Sitemap with default wiki namespace only

The problem is that the generated sitemap contains all wiki namespaces. Fortunately, the links are broken down into the files where each file contains only links to particular namespace.


It is easy to modify the XML file to remove all references except for the NS_0-0 only which lists links to default namespace. Open ./maintenance/sitemap/sitemap-index-example.xml file in editor and modify it to something similar:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <sitemap>
                <loc>http://example.com/wiki/maintenance/sitemap/sitemap-example-NS_0-0.xml.gz</loc>
                <lastmod>2012-03-24T10:26:45Z</lastmod>
        </sitemap>
</sitemapindex>

References