From c37a429b9b433ca765e18cd3d3d63f9bdf5c03a8 Mon Sep 17 00:00:00 2001 From: eecavanna Date: Mon, 16 Dec 2024 12:47:38 -0800 Subject: [PATCH] Implement Sphinx-themed Error 404 page using Sphinx extension --- content/home/requirements.txt | 6 +++++- content/home/src/conf.py | 17 ++++++++++++++--- content/legacy_home/requirements.txt | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/content/home/requirements.txt b/content/home/requirements.txt index 83dac51..658b35c 100644 --- a/content/home/requirements.txt +++ b/content/home/requirements.txt @@ -2,6 +2,10 @@ myst-parser sphinx_markdown_tables sphinx_rtd_theme -# Sphinx plugin that handles redirects. +# Sphinx extension that handles redirects. # Reference: https://pypi.org/project/sphinx-reredirects/ sphinx-reredirects + +# Sphinx extension that creates a `404.html` page in which static assets are properly referenced. +# Reference: https://sphinx-notfound-page.readthedocs.io +sphinx-notfound-page==1.0.4 diff --git a/content/home/src/conf.py b/content/home/src/conf.py index 026e960..7ef9a25 100644 --- a/content/home/src/conf.py +++ b/content/home/src/conf.py @@ -32,9 +32,10 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'myst_parser', - 'sphinx_markdown_tables', - 'sphinx_reredirects', + 'myst_parser', + 'sphinx_markdown_tables', + 'sphinx_reredirects', + 'notfound.extension', ] # source_suffix = '.rst' @@ -97,6 +98,16 @@ "reference/metadata/*": "https://w3id.org/nmdc/nmdc", } +# -- Sphinx Not Found Page extension -------------------- +# +# Reference: https://sphinx-notfound-page.readthedocs.io/en/latest/configuration.html +# +notfound_urls_prefix = None +notfound_context = { + "title": "Page Not Found", + "body": "

Page Not Found

\n\nWe failed to find a page at that address.", +} + # -- Sphinx Read The Docs Theme ------------------------- # # Configure "Edit on GitHub" links. diff --git a/content/legacy_home/requirements.txt b/content/legacy_home/requirements.txt index 83dac51..a94955b 100644 --- a/content/legacy_home/requirements.txt +++ b/content/legacy_home/requirements.txt @@ -2,6 +2,6 @@ myst-parser sphinx_markdown_tables sphinx_rtd_theme -# Sphinx plugin that handles redirects. +# Sphinx extension that handles redirects. # Reference: https://pypi.org/project/sphinx-reredirects/ sphinx-reredirects