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

Link canonical documentation to discourage search engines from linking old docs #12363

Closed
jfrost-mo opened this issue May 24, 2024 · 1 comment · Fixed by #12364
Closed

Link canonical documentation to discourage search engines from linking old docs #12363

jfrost-mo opened this issue May 24, 2024 · 1 comment · Fixed by #12364

Comments

@jfrost-mo
Copy link
Contributor

What's the problem this feature will solve?

Currently when you search for a pytest feature on the web you often get linked to an old version of the documentation. This isn't ideal, as newer versions of the documentation have improvements, and its also rare that you are running the multi year old version that is often linked to.

Describe the solution you'd like

Fortunately this situation can be resolved by adding a <link rel="canonical" href="url of page in stable version"> tag onto all of the documentation pages. This can be done with sphinx by specifying the html_baseurl in the conf.py.

html_baseurl = "https://docs.pytest.org/en/stable/"

This would cause search engines indexing older versions of the page, as well as versions on other domains, such as the readthedocs.io temporary URLs, to relate all of these pages in the index, and show the canonical one in search results. After a few months the old pages should disappear from search results, and only the stable version will be shown.

Alternative Solutions

According to the documentation, ReadTheDocs should already be adding this, however it doesn't seem to be present on any pages. According to a different part of the ReadTheDocs docs, you might need to enable this for custom domains:

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 Admin > Domains section of your project settings.

It is worth checking if that is set first, before doing anything here.

@nicoddemus
Copy link
Member

nicoddemus commented May 24, 2024

@jfrost-mo that's good to know, thanks a lot for detailing this.

I'm all up for it, would you like to open a PR with that?

@jfrost-mo jfrost-mo changed the title Link canonical documentation to discourage search engines from linking old docs. Link canonical documentation to discourage search engines from linking old docs May 24, 2024
nicoddemus pushed a commit that referenced this issue May 26, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
nicoddemus pushed a commit that referenced this issue May 30, 2024
This is used to set the <link rel="canonical" href="X"> tag that points to the canonical version of the webpage. Including this indicates to search engines which version to include in their indexes, and should prevent older versions showing up.

Fixes #12363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants