Merge branch 'canonical_url_support' of https://github.com/Nobatek/sphinx_rtd_theme into Nobatek-canonical_url_support

This commit is contained in:
Eric Holscher 2017-03-04 19:13:32 -08:00
commit 82484eb5b5
4 changed files with 18 additions and 1 deletions

View File

@ -49,6 +49,15 @@ In your ``conf.py`` file:
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
You may also specify a canonical url in conf.py to let search engines know
they should give higher ranking to latest version of the docs:
.. code:: python
html_theme_options['canonical_url'] = 'http://domain.tld/latest/docs/'
The url points to the root of the documentation. It requires a trailing slash.
Via git or download
-------------------

View File

@ -22,6 +22,10 @@
{% if favicon %}
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
{% endif %}
{# CANONICAL URL #}
{% if theme_canonical_url %}
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html"/>
{% endif %}
{# CSS #}

View File

@ -126,6 +126,9 @@
{%- if favicon %}
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
{%- endif %}
{%- if theme_canonical_url %}
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html"/>
{%- endif %}
{%- endif %}
{%- block linktags %}
{%- if hasdoc('about') %}

View File

@ -11,3 +11,4 @@ collapse_navigation = False
display_version = True
navigation_depth = 4
prev_next_buttons_location = bottom
canonical_url =