Skip to content

Commit

Permalink
Sphinx: use html_baseurl for setting the canonical URL
Browse files Browse the repository at this point in the history
  • Loading branch information
stsewd committed Oct 6, 2020
1 parent 2d64328 commit c76e363
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ context = {
'commit': {% if project.repo_type == 'git' %}'{{ commit|slice:"8" }}'{% else %}'{{ commit }}'{% endif %},
}

# For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
if version_info >= (1, 8):
if not globals().get('html_baseurl'):
html_baseurl = context['canonical_url']
context['canonical_url'] = None


{# Provide block for extending context data from child template #}
{% block extra_context %}{% endblock %}

Expand Down

0 comments on commit c76e363

Please sign in to comment.