Skip to content

Add a themed 404 page and a page-level sitemap - #217

Merged
tillig merged 1 commit into
mainfrom
feature/sitemap-and-404
Sep 3, 2026
Merged

tillig merged 1 commit into
mainfrom
feature/sitemap-and-404

Conversation

@tillig

@tillig tillig commented Sep 3, 2026

Copy link
Copy Markdown
Member

Adds sphinx-notfound-page and sphinx-sitemap.

Why each one

404 page. On a custom domain, Read the Docs serves a generic 404 that has none of our theme or navigation. sphinx-notfound-page generates a 404.html that Read the Docs serves instead. The subtlety is that a 404 is served from any URL depth, so relative asset links would break — the extension rewrites them absolute:

href="/en/latest/_static/styles/furo.css?v=7bdb33bb"

Verified: 28 KB, Furo-themed (sidebar-drawer markup present), and zero remaining ../ links.

Sitemap. Read the Docs generates a sitemap.xml listing version roots, not individual pages. sphinx-sitemap complements it with a page-level sitemap — 93 URLs.

The two settings that aren't obvious

html_baseurl was not previously set. It does double duty: Sphinx emits it as <link rel="canonical">, and sphinx-sitemap builds every URL from it.

<link rel="canonical" href="https://docs.autofac.org/en/latest/register/registration.html">

sitemap_url_scheme = '{link}' is required because of that value. html_baseurl already carries the language and version, and the default scheme ({lang}{version}{link}) would repeat both — and would use version from conf.py (9.0) rather than the latest the site is actually served at, producing URLs that 404.

sitemap_excludes drops 404.html, search.html and genindex.html. The 404 in particular should never be advertised to a crawler; it was in the first build I ran. glossary.html is real content and stays.

Verification

  • sphinx -b html -W --keep-going — succeeds, zero warnings
  • Sitemap 96 → 93 URLs after exclusions, exactly the three dropped, no doubled en/latest prefix
  • doc8, pre-commit run --all-files, npm run lint — all clean

Read the Docs serves a generic 404 for a custom domain, losing the site's
theme and navigation; sphinx-notfound-page generates one it serves instead.
Its links have to be absolute, since a 404 is served from any depth.

Read the Docs' own sitemap.xml lists version roots, so sphinx-sitemap
complements it with the individual pages.
@tillig
tillig merged commit c1e22ef into main Sep 3, 2026
2 checks passed
@tillig
tillig deleted the feature/sitemap-and-404 branch September 3, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant