Serve 404/index.html file for htmldir Sphinx builder
@@ -145,7 +145,7 @@ def server_error_404_subdomain(request, template_name='404.html'):
the Docs default page (Maze Found) is rendered by Django and served.
"""
- def resolve_404_path(project, version_slug=None, language=None):
+ def resolve_404_path(project, version_slug=None, language=None, filename='404.html'):
"""
Helper to resolve the path of ``404.html`` for project.
@@ -159,7 +159,7 @@ def server_error_404_subdomain(request, template_name='404.html'):
project,
version_slug=version_slug,
language=language,
- filename='404.html',
+ filename=filename,
subdomain=True, # subdomain will make it a "full" path without a URL prefix
)
@@ -197,7 +197,8 @@ def server_error_404_subdomain(request, template_name='404.html'):
# Firstly, attempt to serve the 404 of the current version (version_slug)
# Secondly, try to serve the 404 page for the default version (project.get_default_version())
for slug in (version_slug, project.get_default_version()):
- basepath, filename, fullpath = resolve_404_path(project, slug, language)
+ for tryfile in ('404.html', '404/index.html'):
+ basepath, filename, fullpath = resolve_404_path(project, slug, language, tryfile)
if os.path.exists(fullpath):
log.debug(
'serving 404.html page current version: [project: %s] [version: %s]',
