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 enable password resets based on the username or email address of users in MediaWiki
- How to update the site statistics in MediaWiki
- MediaWiki Extensions Installation and Management
- How to capitalize and make uppercase page titles and subheadings in MediaWiki
- How to display a site notice at the top of pages in MediaWiki