From 2f1b2ec1302a78f98a67bda8aee76baa96240330 Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Wed, 11 Jan 2023 17:18:03 +0100 Subject: [PATCH] Entirely remove "index.html" from canonical URL if the dirhtml builder was used --- sphinx_rtd_theme/layout.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index 9b00d0320..af8d59057 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -65,7 +65,10 @@ Workaround for: https://github.com/sphinx-doc/sphinx/issues/9730 Once a fix is released in Sphinx, put an upper bound on the Sphinx version for the workaround -#} - {%- if builder == 'dirhtml' and pageurl.endswith('.html') %} + {%- if builder == 'dirhtml' and pageurl.endswith('index.html') %} + {#- This expression trims away index.html entirely #} + + {%- elif builder == 'dirhtml' and pageurl.endswith('.html') %} {#- This expression trims away .html and adds a / #} {%- else %}