Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: tell users to set the canonical URL manually #11455

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions docs/user/canonical-urls.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ and this is one of the suggested ways to solve it from search engines.

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

.. tip::

In most cases, Read the Docs will automatically generate a canonical URL for Sphinx projects.
Most Sphinx users do not need to take further action.

.. seealso::

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

.. note::

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.

Implementation
--------------
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.

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

.. code-block:: html
How to specify the canonical URL
--------------------------------

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