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.2.tar.gz (5.2 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.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for simple_sphinx_xml_sitemap-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2683067e537db0bac942940a6ca6ff30f5b3a813666495c7efe483cf1e59ff81
MD5 ee74121282379d585b416747835e5ad8
BLAKE2b-256 c98827a72400b9d44989e0e3cc8e1e24a908787fc2c842f2197d57b50f62211f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for simple_sphinx_xml_sitemap-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5bec97958981ff4469ef35eaed47e1e43112c366890a3914c1c3f6c7c7b73f51
MD5 7986afd801cd37be7082d0d34f1d6363
BLAKE2b-256 74460c1e500b07ba96fce2ed1467a2a2008ca0f65033bb69a8ceee8ca002a41d

See more details on using hashes here.

Provenance

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