Sphinx Sitemap Generator Extension

2.9.0 · active · verified Tue Apr 14

Sphinx-sitemap is a Sphinx extension designed to automatically generate sitemaps.org compliant XML sitemaps for the HTML version of your Sphinx documentation. It supports multi-version and multi-language documentation, enhances SEO, and can include 'last modified' timestamps. The current version is 2.9.0, released on October 5, 2025.

Warnings

Install

Imports

Quickstart

To get started, install the library and then enable the extension by adding 'sphinx_sitemap' to the `extensions` list in your Sphinx `conf.py`. Crucially, set the `html_baseurl` configuration variable to the root URL where your documentation will be hosted for correct sitemap generation.

# In conf.py, typically located in your Sphinx project's root directory

import os

project = 'My Awesome Docs'
copyright = '2026, Your Name'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx_sitemap',  # Add this line to enable the extension
]

# *** ESSENTIAL for sitemap generation ***
# Set the base URL of your published documentation. This is critical for sitemap validity.
html_baseurl = os.environ.get('DOCS_BASE_URL', 'https://example.com/docs/')

# Optional: Enable 'lastmod' timestamps (requires Git repository with history)
# sitemap_show_lastmod = True

# Optional: Exclude specific pages or patterns from the sitemap
# sitemap_exclude_pages = ['excluded_page.html', '**/private/*']

# To generate the sitemap, navigate to your docs directory and run:
# sphinx-build -b html . _build
# The sitemap.xml will be generated in the _build directory.

view raw JSON →