Ad

The Canonical Link Points To The Site Root Error

I have a website that uses country-specific pages. So for every page, there is a country-specific URL. For example: example.com/au/blog, example.com/us/blog, example.com/uk/blog. This is great as we can show content more relevant to each country.

This idea is the same for our home page: example.com/au, example.com/us, example.com/uk.

When a user goes to a non-country specific URL (ie example.com, example.com/blog) the server falls back to serving more generalised content. On the client, we then show a banner for the user to decide if they want to go to a country-specific page.

With this in mind, I have added the following meta tags and receiving the below error when testing using Lighthouse.

<link rel="canonical" href="https://www.example.com/">
<link rel="alternate" hreflang="x-default" href="https://www.example.com/">
<link rel="alternate" hreflang="en-GB" href="https://www.example.comt/uk/">
<link rel="alternate" hreflang="en-US" href="https://www.example.com/us/">
<link rel="alternate" hreflang="en-AU" href="https://www.example.com/au/">
//error
The document does not have a valid rel=canonical. Points to the domain's root URL (the homepage), instead of an equivalent page of content. 

Is this the correct way to inform crawlers that:

  • The site root is the original document
  • The site root doesn't target any language or locale
  • The alternatives to this page are en-GB, en-US and en-AU

If so, why does Lighthouse complain about this error on the home page? It doesn't complain about this on any other page.

I am new to canonicalisation and providing alternative lang pages so I might be missing something obvious.

Ad

Answer

Since your home page has a generalized subset of content, it is not canonical. (The canonical context IRI and target IRI shouldn't be the same or the user would already be on the canonical IRI.) Technically, the per language IRIs are canonical and alternate documents, depending on the language. Since you're in the UK, you should specify the en-GB IRI to be the canonical IRI and the others to be alternates (not "alternatives") since they are simply different representations of the same content therein.

From the home page https://www.example.com/ (the generalized content):

<link rel="canonical" hreflang="en-GB" href="https://www.example.com/uk/">
https://www.example.com/ (the generalized content):

<link rel="canonical" hreflang="en-GB" href="https://www.example.com/uk/">

From https://www.example.comt/uk/ (the canonical IRI)

<link rel="alternate" hreflang="en-US" href="https://www.example.com/us/">
<link rel="alternate" hreflang="en-AU" href="https://www.example.com/au/">

https://www.rfc-editor.org/rfc/rfc6596

https://www.rfc-editor.org/rfc/rfc8288

https://html.spec.whatwg.org/#the-link-element

Ad
source: stackoverflow.com
Ad