Skip to content

Commit

Permalink
Use canonical URL from html_baseurl
Browse files Browse the repository at this point in the history
  • Loading branch information
stsewd committed Oct 7, 2020
1 parent 006cd21 commit 54f7ead
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.rst
Expand Up @@ -5,6 +5,11 @@ Changelog
master
======

Other Changes
-------------

* The ``canonical_url`` option was removed in favor of Sphinx's ``html_baseurl``.

v0.5.0
======

Expand Down
14 changes: 3 additions & 11 deletions docs/configuring.rst
Expand Up @@ -13,7 +13,6 @@ For example:
.. code:: python
html_theme_options = {
'canonical_url': '',
'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
'logo_only': False,
'display_version': True,
Expand Down Expand Up @@ -103,13 +102,9 @@ Miscellaneous options

.. confval:: canonical_url

:type: URL
.. waning:: Option removed in 0.6.0

This will specify a `canonical URL`_ meta link element to tell search
engines which URL should be ranked as the primary URL for your
documentation. This is important if you have multiple URLs that your
documentation is available through. The URL points to the root path of the
documentation and requires a trailing slash.
Use the :confval:`sphinx:html_baseurl` option from Sphinx instead.

.. confval:: display_version

Expand Down Expand Up @@ -157,10 +152,7 @@ Miscellaneous options
:default: ``#2980B9``

Changes the background of the search area in the navigation bar. The value
can be anything valid in a CSS `background` property.

.. _canonical URL: https://en.wikipedia.org/wiki/Canonical_link_element

can be anything valid in a CSS `background` property.

File-wide metadata
==================
Expand Down
7 changes: 4 additions & 3 deletions sphinx_rtd_theme/layout.html
Expand Up @@ -38,10 +38,11 @@
{% 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 %}
{%- if pageurl %}
<link rel="canonical" href="{{ pageurl|e }}" />
{%- endif %}

{# JAVASCRIPTS #}
{%- block scripts %}
Expand Down
3 changes: 1 addition & 2 deletions sphinx_rtd_theme/theme.conf
Expand Up @@ -4,7 +4,6 @@ stylesheet = css/theme.css
pygments_style = default

[options]
canonical_url =
analytics_id =
collapse_navigation = True
sticky_navigation = True
Expand All @@ -15,4 +14,4 @@ logo_only =
display_version = True
prev_next_buttons_location = bottom
style_external_links = False
style_nav_header_background =
style_nav_header_background =

0 comments on commit 54f7ead

Please sign in to comment.