magento / devdocs

[Deprecated] Magento Developer Documentation
Open Software License 3.0
674 stars 1.76k forks source link

Add canonical URLs to all older versions of the same page. #1849

Closed paales closed 5 years ago

paales commented 6 years ago

I often encounter URL's in Google that direct to an old URL.

For example, when I google on 'magento 2.3 installation composer', the first hit is http://devdocs.magento.com/guides/v2.0/install-gde/prereq/integrator_install_composer.html

Now, the 2.0 documentation is out of date for most intents and purposes, so it would be great if Google would point to the 2.2 documentation (and move to 2.3 after its release).

To achieve this you can add a canonical meta tag, so that Google knows that the 2.0 page isn't the canonical source any more. This also increases ranking as all the 'SEO juice' goes to the latest version, improving ranking if multiple version score for that page. Also it will prevent duplicate-content penalties by Google.

jeff-matthews commented 6 years ago

Thanks for the feedback @paales! Every page currently contains a canonical URL. We use liquid templating in the _includes/header.html file like so:

<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">

What you seem to be suggesting is that we hard code all 2.0 canonical links to the latest version (2.2), but that may be problematic when 2.2 is no longer the latest version. Perhaps we need to revisit how we're building canonical links so that we're always building links with the latest version.

paales commented 6 years ago

If 2.2 isn't the canonical URL anymore, all the URL's need to change to 2.3, 2.4, etc. If that requires some refactoring, that is fine by me 😛.

jeff-matthews commented 6 years ago

This may not be a trivial change since we're using the page.baseurl variable to retrieve the file path, which includes the version number. I'm not sure how we would separate the version number from the path. We've updated our robots.txt file to stop indexing 2.0 files, which should help with issues like this in the future.

paales commented 6 years ago

@jeff-matthews That seems like a very bad Idea as you need to rebuild your ranking each time a new version is released.

jeff-matthews commented 6 years ago

That's a good point. We'll do some more research to see what options we have.

@belbiy, do you have any thoughts?

jeff-matthews commented 6 years ago

I discussed this with the doc team and we came up with a good solution I think.

First of all, we stopped noindexing the 2.0 directory.

Second, we're planning to change the project architecture and branching workflow to remove the version number from the URL of the latest version of a topic. When you select an earlier version of a topic, that URL will contain the version number, but the canonical link for that version will point to the latest version. This will prevent canonical links from pointing to old versions and confusing search engines and eliminate the need to update canonical links every time we release a new minor version.

paales commented 6 years ago

That sounds like a great solution :)

jeff-matthews commented 6 years ago

We've just finished scoping and planning the internal project that will solve this issue. Will update when more info is available, but we expect to complete this by the end of the year.

jeff-matthews commented 5 years ago

PR https://github.com/magento/devdocs/pull/3462 will use the latest version for canonical URLs. When we implement our new branch versioning project, we'll revisit this as needed. In the meantime, this, along with the new sitemap.xml file should mitigate these SEO issues.

jeff-matthews commented 5 years ago

This PR is also related https://github.com/magento/devdocs/pull/3463.