Sitemaps
XML sitemaps help search engines discover and index pages on your wiki. Canasta provides commands to generate and remove sitemaps, and a background process to keep them up to date.
Why sitemaps matter
Search engines like Google and Bing use XML sitemaps to discover pages on your site. Without a sitemap, crawlers rely on following links from your main page, which can miss pages that are poorly linked or deeply nested. Providing a sitemap ensures that all your wiki's content is discoverable.
Generating sitemaps
Use canasta sitemap generate to create sitemaps for your wikis.
Generate a sitemap for a specific wiki:
canasta sitemap generate -w mywiki
Generate sitemaps for all wikis in the instance:
canasta sitemap generate
Once generated, a background process automatically keeps the sitemaps up to date.
Redirect pages
Redirect pages are automatically excluded from sitemaps (via MediaWiki's --skip-redirects flag). Since redirect pages point to other pages that are already in the sitemap, including them would add no value for search engines and unnecessarily increase the sitemap size.
Filtering namespaces
You can control which namespaces are included in sitemaps by setting $wgSitemapNamespaces in a settings file (e.g., config/settings/global/Sitemaps.php). For example, to include only the main namespace and the Help namespace:
$wgSitemapNamespaces = [ NS_MAIN, NS_HELP ];
If $wgSitemapNamespaces is not set, MediaWiki includes all namespaces by default.
Sitemap identifier
A wiki's sitemap files are named after its identifier, which is the wiki ID by default: its index is sitemap-index-<identifier>.xml. To keep an index URL search engines already know, such as sitemap-index-mediawiki.xml, give the wiki that identifier when generating:
canasta sitemap generate -w mywiki --identifier mediawiki
The identifier is stored as the wiki's sitemap_identifier in config/wikis.yaml, which the background refresh uses too, and the files of the wiki's previous identifier are removed. It may contain letters, digits, _, - and ., and starts with a letter or digit. Passing the wiki ID restores the default. On a gitops-managed Kubernetes instance the change is staged for canasta gitops push, and the files are renamed once it is deployed.
Removing sitemaps
Use canasta sitemap remove to delete sitemap files. Once removed, the background generator will skip those wikis until sitemaps are generated again.
Remove the sitemap for a specific wiki. The wiki ID must be one of the instance's wikis in config/wikis.yaml; an unknown ID is refused:
canasta sitemap remove -w mywiki
Remove sitemaps for all wikis (prompts for confirmation):
canasta sitemap remove
Background refresh
After sitemaps are generated for a wiki, a background process inside the container automatically refreshes them on a regular schedule. The refresh interval is controlled by the MW_SITEMAP_PAUSE_DAYS setting, which defaults to 1 (day). Values less than 1 are treated as 1.
To change the refresh interval:
canasta config set MW_SITEMAP_PAUSE_DAYS=7
The background generator runs continuously inside the container — it starts after a 30-second delay and loops indefinitely, sleeping for the configured interval between runs. It only refreshes sitemaps for wikis that already have sitemap files — generating sitemaps for a wiki opts it in, and removing them opts it out.
The generator writes daily-rotating log files inside the container at /var/log/mediawiki/mwsitemapgen_log_YYYYMMDD.
File storage
Sitemap files are stored in the public_assets/<wiki-id>/sitemap/ directory within your instance. They are served at MW_SITEMAP_URL_PATH relative to the wiki's URL, which is /public_assets/sitemap/ by default (/docs/public_assets/sitemap/ for a wiki at example.com/docs); see Sitemap URL path.
myinstance/
public_assets/
mywiki/
sitemap/
sitemap-mywiki-NS_0-0.xml.gz
sitemap-mywiki-NS_6-0.xml.gz
sitemap-index-mywiki.xml
The file(s) are compressed (.xml.gz) for efficiency, with an index file that lists all the individual sitemap files.
Sitemap URL path
MW_SITEMAP_URL_PATH sets the URL path, relative to each wiki's URL, at which the instance's wikis publish their sitemaps. It defaults to /public_assets/sitemap. To publish them under the wikis' own article path, for example behind a proxy or CDN that forwards only /wiki/ URLs:
canasta config set MW_SITEMAP_URL_PATH=/wiki/sitemap
A wiki at example.com/docs then publishes its index at https://example.com/docs/wiki/sitemap/sitemap-index-docs.xml. The files stay in public_assets/<wiki-id>/sitemap/: Caddy serves the configured path from them, and the HAProxy edge treats it as the instance's static files. config set restarts the instance, and the background refresh that follows writes the new URLs into the indexes.
The path starts with /, uses letters, digits and -, _, . and ~ between slashes, and has no .. and no trailing slash. It cannot be /wiki, nor /w or /public_assets or a path under them, which MediaWiki's own pages and files use.
A path under the article path, such as /wiki/sitemap, is served from the sitemap files rather than by MediaWiki. A page whose title starts with sitemap/ is then reachable only by its capitalized title (Sitemap/...), and not at all on a wiki with $wgCapitalLinks = false.
In a wiki farm, a wiki's sitemap path cannot contain another wiki's URL on the same host, or lie inside one other than a URL its own wiki's URL lies within. With a root wiki at example.com and a wiki at example.com/docs, MW_SITEMAP_URL_PATH=/docs/sitemap would put the root wiki's sitemaps inside the docs wiki, so canasta config set refuses it, and canasta add refuses a wiki whose URL would overlap that way. If such a combination arrives another way (a gitops pull, a restore or a hand-edited file), the affected wiki's sitemaps are not served at that path, which stays with the wiki that owns it, and a warning naming both wikis is printed when the instance starts or restarts and by canasta sitemap generate.
The setting needs a Canasta image of 3.5.30 or later; older images ignore it.
robots.txt integration
Canasta dynamically generates robots.txt for each host. When sitemap files exist for any wiki on the host, it names the host's combined sitemap index, /sitemap.xml, which lists the sitemaps of every wiki on that host at their published URLs:
Sitemap: https://example.com/sitemap.xml
No configuration is needed — the presence of sitemap files is the sole signal. When sitemaps are removed, the robots.txt entry is removed as well.
Disabling robots
To tell all search engines not to crawl any of your wikis, set ROBOTS_DISALLOWED=true in your .env file. This causes robots.txt to return Disallow: / for all user agents.
Verifying sitemaps
After generating sitemaps, verify they are accessible:
- Check the sitemap index URL in your browser:
https://example.com/public_assets/sitemap/sitemap-index-mywiki.xml
- Verify
robots.txtincludes the sitemap URL:https://example.com/robots.txt
- Submit the sitemap URL to search engine webmaster tools for faster indexing:
Troubleshooting
Sitemaps not updating
- Verify the containers are running:
canasta start -i myinstance - Check the
MW_SITEMAP_PAUSE_DAYSvalue in your.envfile — a high value means less frequent refreshes - Check the generator log inside the container for errors:
/var/log/mediawiki/mwsitemapgen_log_YYYYMMDD - Regenerate manually:
canasta sitemap generate -i myinstance -w mywiki
Search engines not finding sitemaps
- Confirm the sitemap URL is present in
robots.txt(visithttps://yourwiki/robots.txt) - If sitemap files exist but
robots.txtdoes not list them, restart the instance:canasta restart -i myinstance - Submit the sitemap URL directly in your search engine's webmaster tools
Permission errors
- Ensure your user is in the
www-datagroup (see Installation guide) - The sitemap directory must be writable by the
www-datauser inside the container —canasta sitemap generatehandles this automatically