Skip to content

Commit 6fb6408

Browse files
committed
Add custom 404 not found page
error page for 404 is available at /404.html
1 parent ada9cff commit 6fb6408

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

docs/_templates/404.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{% extends "!page.html" %}
2+
3+
{%- block htmltitle %}
4+
<title>{{ title|striptags|e }}{%- for parent in parents %} – {{ parent.title }}{%- endfor %}{{ titlesuffix }}</title>
5+
{%- endblock %}
6+
7+
{% block body %}
8+
<div>
9+
<h1>Page not found</h1>
10+
<p>Unfortunately we couldn't find the content you were looking for.</p>
11+
</div>
12+
13+
<style>
14+
/* Hide empty sub menu. */
15+
.sticky-top .bd-toc {
16+
visibility: hidden;
17+
}
18+
</style>
19+
{% endblock %}

docs/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"sphinxext.opengraph",
5656
"sphinx.ext.viewcode", # plone.api
5757
"sphinx.ext.autosummary", # plone.api
58+
"notfound.extension",
5859
]
5960

6061

@@ -206,6 +207,12 @@
206207
copybutton_prompt_is_regexp = True
207208

208209

210+
# -- sphinx-notfound-page configuration ----------------------------------
211+
212+
notfound_urls_prefix = None
213+
notfound_template = "404.html"
214+
215+
209216
# -- Options for HTML output -------------------------------------------------
210217

211218
# The theme to use for HTML and HTML Help pages. See the documentation for

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ sphinx-togglebutton
1414
sphinxcontrib.httpdomain # plone.restapi
1515
sphinxcontrib.httpexample # plone.restapi
1616
sphinxext-opengraph
17+
sphinx-notfound-page

0 commit comments

Comments
 (0)