diff --git a/README.rst b/README.rst index 18a23ae7..e4c04934 100644 --- a/README.rst +++ b/README.rst @@ -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 ------------------- diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index a0e62e1f..2ccae0b5 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -22,6 +22,10 @@ {% if favicon %} {% endif %} + {# CANONICAL URL #} + {% if theme_canonical_url %} + + {% endif %} {# CSS #} diff --git a/sphinx_rtd_theme/layout_old.html b/sphinx_rtd_theme/layout_old.html index f0dc2af6..9f2d1999 100644 --- a/sphinx_rtd_theme/layout_old.html +++ b/sphinx_rtd_theme/layout_old.html @@ -126,6 +126,9 @@ {%- if favicon %} {%- endif %} + {%- if theme_canonical_url %} + + {%- endif %} {%- endif %} {%- block linktags %} {%- if hasdoc('about') %} diff --git a/sphinx_rtd_theme/theme.conf b/sphinx_rtd_theme/theme.conf index 218fc996..f96b5840 100644 --- a/sphinx_rtd_theme/theme.conf +++ b/sphinx_rtd_theme/theme.conf @@ -4,10 +4,11 @@ stylesheet = css/theme.css [options] typekit_id = hiw1hhg -analytics_id = +analytics_id = sticky_navigation = False logo_only = collapse_navigation = False display_version = True navigation_depth = 4 prev_next_buttons_location = bottom +canonical_url =