Skip to main content

A simple Sphinx extension that generates an XML sitemap from navigation pages.

Project description

Simple Sphinx XML Sitemap Extension

CI

This project provides a minimal Sphinx extension that generates an XML sitemap for your documentation. The extension inspects the navigation structure of your project and writes a sitemap.xml file after the HTML build step completes.

The extension does not support internationalisation or multiple languages, but it is suitable for most single language documentation sites.

Installation

Install from PyPI using pip:

pip install simple-sphinx-xml-sitemap

Alternatively add it to your pyproject.toml or requirements.txt file.

Usage

Add the extension to the extensions list in your Sphinx conf.py file and set html_baseurl to the public URL where the documentation will be hosted.

extensions = [
    # other extensions
    'simple_sphinx_xml_sitemap',
]

html_baseurl = 'https://example.com/docs/'

Build your documentation as normal. The sphinx-build command becomes available after installing the project's dependencies (for example with uv):

sphinx-build -b html docs docs/_build

After the build completes a sitemap.xml file will be present in the output folder.

Examples

The examples/ directory contains small projects showing different ways to use the extension. The project is configured as a uv workspace so these examples can declare simple-sphinx-xml-sitemap as a dependency in their own pyproject.toml files.

docs

This directory contains only a Sphinx project. To build it run:

cd examples/docs
uv venv
source .venv/bin/activate
uv pip install -e .
sphinx-build -b html . _build

The example conf.py excludes the .venv directory created above so that Sphinx does not try to parse files inside the virtual environment.

hello_world

This example is a tiny Python package with a documentation folder and its own pyproject.toml. Build the docs and install the package in editable mode:

cd examples/hello_world
uv venv
source .venv/bin/activate
uv pip install -e .
sphinx-build -b html docs docs/_build

Both examples will produce a sitemap.xml alongside the HTML output.

Running the tests

Create a virtual environment using uv, install the development dependencies, and run the tests with pytest -q:

uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
pytest -q

Why

Search engines often crawl every file of a Sphinx build, including sources and module documentation pages that may not be useful. Providing an XML sitemap allows you to indicate which pages are important and helps search engines index your documentation correctly.

Project details


Download files

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

Source Distribution

simple_sphinx_xml_sitemap-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_sphinx_xml_sitemap-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file simple_sphinx_xml_sitemap-0.1.0.tar.gz.

File metadata

File hashes

Hashes for simple_sphinx_xml_sitemap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a725b3b2d5f91fef5195185f1ee6c6903b9f4b13daecf478779cb7df5a1f5e9f
MD5 c11f63fbb1f84cbb90ba162a6bed595a
BLAKE2b-256 755b7ead8ca69cf1d147f29f9c573de77385a14a7486d9cba1f8d71157a14807

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_sphinx_xml_sitemap-0.1.0.tar.gz:

Publisher: publish.yml on mdrideout/simple-sphinx-xml-sitemap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_sphinx_xml_sitemap-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_sphinx_xml_sitemap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3813716e19d44bd1e92aa81b344bfceeceaf1b03c601c56740c954eb10179f67
MD5 15c1bedfd5e5d6b3a0deb7e4b158a64c
BLAKE2b-256 7248158a29f4fd712561ac9a3ab03a7d76e1d05bd46fbe1d49a99fb843f5e6da

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_sphinx_xml_sitemap-0.1.0-py3-none-any.whl:

Publisher: publish.yml on mdrideout/simple-sphinx-xml-sitemap

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page