File tree 2 files changed +18
-0
lines changed
readthedocs/doc_builder/templates/doc_builder
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,16 @@ Check your :guilabel:`Admin` > :guilabel:`Domains` page for the domains that we
31
31
Implementation
32
32
--------------
33
33
34
+ If you are using :doc: `Sphinx </intro/getting-started-with-sphinx >`,
35
+ Read the Docs will set the value of the html_baseurl _ setting (if isn't already set) to your canonical domain.
36
+
37
+ .. _html_baseurl : https://www.sphinx-doc.org/page/usage/configuration.html#confval-html_baseurl
38
+
39
+ If you are using :doc: `MkDocs </intro/getting-started-with-mkdocs >`,
40
+ you can use the site_url _ setting.
41
+
42
+ .. _site_url : https://www.mkdocs.org/user-guide/configuration/#site_url
43
+
34
44
If you look at the source code for documentation built after you set your canonical URL,
35
45
you should see a bit of HTML like this:
36
46
Original file line number Diff line number Diff line change @@ -120,6 +120,14 @@ context = {
120
120
'commit': {% if project.repo_type == 'git' %}'{{ commit|slice:"8" }}'{% else %}'{{ commit }}'{% endif %},
121
121
}
122
122
123
+ # For sphinx >=1.8 we can use html_baseurl to set the canonical URL.
124
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
125
+ if version_info >= (1, 8):
126
+ if not globals().get('html_baseurl'):
127
+ html_baseurl = context['canonical_url']
128
+ context['canonical_url'] = None
129
+
130
+
123
131
{# Provide block for extending context data from child template #}
124
132
{% block extra_context %}{% endblock %}
125
133
You can’t perform that action at this time.
0 commit comments