Sphinx Not Found Page

1.1.0 · active · verified Sun Apr 12

Sphinx-notfound-page is a Sphinx extension that automates the creation of custom 404 Not Found pages for Sphinx documentation. It correctly handles absolute URLs for assets such as JavaScript, CSS, and images, which is a common issue with manually created 404 pages. Developed and maintained by Read the Docs, it aims for compatibility across various hosting environments. The current version is 1.1.0, with releases typically addressing bug fixes and Sphinx compatibility updates.

Warnings

Install

Imports

Quickstart

To quickly enable `sphinx-notfound-page`, install it via pip and then add `'notfound.extension'` to the `extensions` list in your Sphinx `conf.py` file. For custom content, you can define `notfound_context` directly in `conf.py` or create a `404.rst` file and set `notfound_template = '404.rst'`. Remember to add `:orphan:` to the top of any custom `404.rst` file to prevent Sphinx warnings.

# conf.py

# Existing extensions list
extensions = [
    # ... other extensions
    'notfound.extension',
]

# Optional: Customize 404 page content directly in conf.py
notfound_context = {
    'title': 'Page Not Found',
    'body': '<h1>Oops! This page does not exist.</h1>\n\n<p>Please check the URL or navigate from the <a href="/">homepage</a>.</p>',
}

# Optional: Use a custom 404.rst file for content
# notfound_template = '404.rst'

# If using a custom 404.rst, ensure it has the :orphan: metadata
# Example 404.rst content (place next to conf.py):
# :orphan:
#
# Error 404: Page Not Found
# =========================
#
# The page you are looking for does not exist. Please check the URL.

view raw JSON →