mirror of
https://github.com/readthedocs/sphinx_rtd_theme.git
synced 2025-02-25 18:55:21 -06:00
Merge ae5cd1bbe5
into 8d4d394dad
This commit is contained in:
commit
3c823cc0c8
@ -13,3 +13,4 @@ python:
|
||||
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
builder: dirhtml
|
||||
|
@ -51,12 +51,26 @@
|
||||
|
||||
{#- CANONICAL URL (deprecated) #}
|
||||
{%- if theme_canonical_url and not pageurl %}
|
||||
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html"/>
|
||||
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}{% if builder == 'dirhtml' %}/{% else %}.html{% endif %}"/>
|
||||
{%- endif -%}
|
||||
|
||||
{#- CANONICAL URL #}
|
||||
{%- if pageurl %}
|
||||
<link rel="canonical" href="{{ pageurl|e }}" />
|
||||
{#-
|
||||
CANONICAL URL
|
||||
NB! pageurl is currently a non-documented template context variable!
|
||||
pageurl implementation: https://www.sphinx-doc.org/en/master/_modules/sphinx/builders/html.html
|
||||
-#}
|
||||
{%- if pageurl -%}
|
||||
{#-
|
||||
pageurl implementation wrongly: adds .html for the dirhtml builder's pageurl
|
||||
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') %}
|
||||
{#- This expression trims away .html and adds a / #}
|
||||
<link rel="canonical" href="{{ (pageurl|e)[:-5] }}/" />
|
||||
{%- else %}
|
||||
<link rel="canonical" href="{{ pageurl|e }}" />
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
|
||||
{#- JAVASCRIPTS #}
|
||||
|
Loading…
Reference in New Issue
Block a user