How to limit the sitemap to specific namespaces in MediaWiki
By default, when you generate a sitemap in MediaWiki it automatically includes the pages from all namespaces in the sitemap. It creates a file for each namespace that has pages in it; that file lists the pages in the particular namespace. You can generate a sitemap with the script generateSitemap.php that comes prepackaged with MediaWiki. For more information check out the article on how to generate a sitemap in MediaWiki.
If you want to, you can restrict the sitemap to particular namespaces so that only pages from these namespaces are added to the sitemap. In this article we'll show you how to do that. For this purpose you only have to add the option $wgSitemapNamespaces to the LocalSettings.php file of your MediaWiki with a list of the ID numbers of the namespaces that you want to include in the sitemap. For example, if you add the following on a new line at the end of LocalSettings.php:
$wgSitemapNamespaces = array( 0, 1, 6, 12, 14, 15 );
this will add to the sitemap the pages from the namespaces Main, Talk, File, Help, Category and Category talk. For a list of the namespaces and their ID numbers check out the article on the reference list of MediaWiki namespaces and their ID numbers and constants.
The LocalSettings.php file is in the root MediaWiki folder on your MediaWiki hosting account. If the application is installed directly in the public_html directory on the account (making the homepage URL yourdomain.com), then the path to the file on the account in relation to that directory will be public_html/LocalSettings.php. HostKnox customers can view and edit files with the File manager of the Pixie control panel. A different way of doing it is to download the file on your local computer with an FTP client, edit it with a text editor (e.g. Notepad ++) and upload it back replacing the old file.
Was this answer helpful?
- How to disable the options for user preferences in MediaWiki
- How to redirect users to a particular page after login in MediaWiki
- How to manage and put your user account signature in comments in MediaWiki
- How to change the expiration time of temporary passwords in MediaWiki
- How to create and manage pages in MediaWiki