Skip to content

Commit db72f81

Browse files
authored
Docs: tell users to set the canonical URL manually (#11455)
Users should start defining the Canonical URL manually using the `READTHEDOCS_CANONICAL_URL` environment variable.
1 parent cf5d387 commit db72f81

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

docs/user/canonical-urls.rst

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ and this is one of the suggested ways to solve it from search engines.
1717

1818
.. _canonical URL: https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls
1919

20-
.. tip::
21-
22-
In most cases, Read the Docs will automatically generate a canonical URL for Sphinx projects.
23-
Most Sphinx users do not need to take further action.
24-
2520
.. seealso::
2621

2722
:doc:`/guides/canonical-urls`
@@ -48,15 +43,14 @@ thus avoiding duplicating the content.
4843

4944
.. note::
5045

51-
If you want your custom domain to be set as the canonical, you need to set ``Canonical: This domain is the primary one where the documentation is served from`` in the :guilabel:`Admin` > :guilabel:`Domains` section of your project settings.
52-
53-
Implementation
54-
--------------
46+
If you want your custom domain to be set as the canonical,
47+
you need to set ``Canonical: This domain is the primary one where the documentation is served from``
48+
in the :guilabel:`Admin` > :guilabel:`Domains` section of your project settings.
5549

56-
A canonical URL is automatically specified in the HTML output with a ``<link>`` element.
57-
For instance, regardless of whether you are viewing this page on ``/en/latest`` or ``/en/stable``,
58-
the following HTML header data will be present:
5950

60-
.. code-block:: html
51+
How to specify the canonical URL
52+
--------------------------------
6153

62-
<link rel="canonical" href="https://docs.readthedocs.io/en/stable/canonical-urls.html" />
54+
A canonical URL is automatically passed to the build process as ``READTHEDOCS_CANONICAL_URL`` :doc:`environment variable </reference/environment-variables>`.
55+
You can use this variable to configure your documentation tool to use it
56+
(eg. Sphinx does this via the ``html_baseurl`` config, MkDocs via ``site_url`` and Pelican with ``SITEURL``)

0 commit comments

Comments
 (0)