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', # note the user of underscores
]

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.1.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.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for simple_sphinx_xml_sitemap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 074156e3afd5f5072626993f880d3977afd683a328161a78c17f79987e8dea0b
MD5 f900ef5eaf35a6c1518fabc41ddfe6c8
BLAKE2b-256 7eef3a39405517b0e44e6b5f7ee32259d074d3cc4b50f0d6437d63744a074273

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_sphinx_xml_sitemap-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_sphinx_xml_sitemap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2e779c4dbec69ef119eda0d9cf49bae9c0b246564d10967b5c3b896a4522f7b
MD5 359809cb0b0f2fea69653fccdadfe95b
BLAKE2b-256 b2f51f210c82beeb8ff87d02c441def4065794ae7d5d09ad06c566039429a4b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_sphinx_xml_sitemap-0.1.1-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