Skip to main content

Sitemap generator for Sphinx

Project description

A Sphinx extension to silently generate a compliant sitemap for the HTML version of your Sphinx Documentation.

Build Status PyPI version License: MIT


Directly install via pip by using:

pip install sphinx-sitemap

Add sphinx_sitemap to the extensions array in your Sphinx For example:

extensions = ['sphinx_sitemap']

Set the value of html_baseurl in your Sphinx to the current base URL of your documentation with a trailing slash. For example:

html_baseurl = ''

Multilingual Configuration

For multilingual sitemaps, you have to generate a sitemap per language/locale and then manually add their locations to a sitemapindex file.

The extension will look at the language config value for the current language being built, and the locale_dirs value for the directory for alternate languages, so make sure those are set.

Note: The extension is currently opinionated, in that it will also use the version config value in the generated URL. Setting it to latest is appropriate for most use cases.

The end result is something like the following for each language/version build:

<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns:xhtml="" xmlns="">
    <xhtml:link href="" hreflang="es" rel="alternate"/>
    <xhtml:link href="" hreflang="fr" rel="alternate"/>
    <xhtml:link href="" hreflang="en" rel="alternate"/>
    <xhtml:link href="" hreflang="es" rel="alternate"/>
    <xhtml:link href="" hreflang="fr" rel="alternate"/>
    <xhtml:link href="" hreflang="en" rel="alternate"/>

Getting the Most out of the Sitemap

  1. Add a robots.txt file in the source directory which contains a link to the sitemap or sitemapindex. For example:

    User-agent: *

    Then, add robots.txt to the html_extra_path config value:

    html_extra_path = ['robots.txt']
  2. Submit the sitemap or sitemapindex to the appropriate search engine tools.

See Who Is Using It

You can use GitHub search or to see who is using sphinx-sitemap.


Pull Requests welcome! See CONTRIBUTING for instructions on how best to contribute.

Maintaining PyPI Version

These are the steps, to be run by the maintainer, for making a new Python package release.

  1. Rev versions in sphinx_sitemap/ and

  2. Update

  3. Create a tag and push to GitHub:

    git tag -a vX.Y.Z -m "Release vX.Y.Z"
    git push --tags origin master
  4. Create latest distribution locally:

    python sdist
  5. Upload to the test repository:

    twine upload --repository-url dist/*
  6. Upload to the production repository:

    twine upload dist/*


sphinx-sitemap is made available under a MIT license; see LICENSE for details.

Originally based on the sitemap generator in the guzzle_sphinx_theme project, also licensed under the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sphinx-sitemap, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size sphinx-sitemap-1.0.2.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page