Sphinx Reredirects

1.1.0 · active · verified Sun Apr 12

Sphinx Reredirects is a Sphinx extension that generates HTML pages with meta refresh redirects for moved or renamed documentation pages, preventing 404 errors. It is currently at version 1.1.0 and is actively maintained with irregular but frequent releases.

Warnings

Install

Imports

Quickstart

To use sphinx-reredirects, first ensure it's added to your `extensions` list in `conf.py`. Then, define the `redirects` dictionary in the same file, mapping old Sphinx document names (without extensions) to their new relative or absolute URL targets. Wildcards and placeholders are supported.

# In your project's conf.py file:

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinx_reredirects'
]

# Define your redirects. Keys are old docnames, values are new URLs.
# Docnames are paths without file extensions (e.g., 'old_chapter/intro' for 'old_chapter/intro.rst').
# Targets can be relative to the project root or absolute URLs.
redirects = {
    "old-page": "new-page.html",
    "removed-feature": "https://external.com/docs/new-home",
    "legacy/*": "current_docs/$source.html" # Wildcard example
}

# To build the documentation and apply redirects:
# sphinx-build -M html source build

view raw JSON →