Skip to content

Commit 6beecce

Browse files
committed
Entirely remove "index.html" from canonical URL if the dirhtml builder was used (retry with GPG signature)
1 parent df87a40 commit 6beecce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sphinx_rtd_theme/layout.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@
6565
Workaround for: https://github.com/sphinx-doc/sphinx/issues/9730
6666
Once a fix is released in Sphinx, put an upper bound on the Sphinx version for the workaround
6767
-#}
68-
{%- if builder == 'dirhtml' and pageurl.endswith('.html') %}
68+
{%- if builder == 'dirhtml' and pageurl.endswith('index.html') %}
69+
{#- This expression trims away index.html entirely #}
70+
<link rel="canonical" href="{{ (pageurl|e)[:-10] }}" />
71+
{%- elif builder == 'dirhtml' and pageurl.endswith('.html') %}
6972
{#- This expression trims away .html and adds a / #}
7073
<link rel="canonical" href="{{ (pageurl|e)[:-5] }}/" />
7174
{%- else %}

0 commit comments

Comments
 (0)