From 6baac191442b649388569cdb780794d22d6e5918 Mon Sep 17 00:00:00 2001 From: Ruth Fuchss Date: Mon, 10 Jul 2023 11:24:27 +0200 Subject: [PATCH] add a custom 404 page Fixes #51. Signed-off-by: Ruth Fuchss --- .sphinx/requirements.txt | 1 + 404.rst | 12 ++++++++++++ conf.py | 10 ++++++++-- custom_conf.py | 4 ++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 404.rst diff --git a/.sphinx/requirements.txt b/.sphinx/requirements.txt index 52eb4c58..d6f37e04 100644 --- a/.sphinx/requirements.txt +++ b/.sphinx/requirements.txt @@ -10,3 +10,4 @@ lxd-sphinx-extensions sphinx-copybutton myst-parser sphinxcontrib-jquery +sphinx-notfound-page diff --git a/404.rst b/404.rst new file mode 100644 index 00000000..050d84ea --- /dev/null +++ b/404.rst @@ -0,0 +1,12 @@ +:orphan: +:nosearch: + +Page not found +============== + +Sorry, but the documentation page that you are looking for was not found. + +Documentation changes over time, and pages are moved around. +We try to redirect you to the updated content where possible, but unfortunately, that didn't work this time (maybe because the content you were looking for does not exist in this version of the documentation). + +You can try to use the navigation to locate the content you're looking for, or search for a similar page. diff --git a/conf.py b/conf.py index 8a26bf29..d7a39453 100644 --- a/conf.py +++ b/conf.py @@ -26,8 +26,9 @@ 'sphinx_copybutton', 'sphinxext.opengraph', 'myst_parser', - 'sphinxcontrib.jquery' - ] + 'sphinxcontrib.jquery', + 'notfound.extension' +] extensions.extend(custom_extensions) ### Configuration for extensions @@ -42,6 +43,11 @@ if 'discourse' in html_context: html_context['discourse_prefix'] = html_context['discourse'] + '/t/' +# The default for notfound_urls_prefix usually works, but not for +# documentation on documentation.ubuntu.com +if slug: + notfound_urls_prefix = '/' + slug + '/en/latest/' + ############################################################ ### General configuration ############################################################ diff --git a/custom_conf.py b/custom_conf.py index 60e892e9..67fae3fc 100644 --- a/custom_conf.py +++ b/custom_conf.py @@ -66,6 +66,10 @@ 'github_issues': 'enabled' } +# If your project is on documentation.ubuntu.com, specify the project +# slug (for example, "lxd") here. +slug = "" + ############################################################ ### Redirects ############################################################