3

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.

Charklewis
  • 4,427
  • 4
  • 31
  • 69

1 Answers1

4

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/">

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

Community
  • 1
  • 1
Rafael
  • 7,605
  • 13
  • 31
  • 46
  • Ah thanks for explaining. I have much more to learn regarding this topic! What tags would go on the site root (ie `/`) then? Would I just be added the alternate pages without marking add a canonical tag? I have updated alternate pages and this has fixed the error on those pages. – Charklewis Jul 31 '20 at 09:51
  • There was a small typo in the context IRI that might have been misleading, but the site root, being generic, should point to the canonical en-GB IRI. – Rafael Jul 31 '20 at 14:23
  • Would you mind explaining why you chose GB as the canonical? The links that are non-region specific (ie `/`, `/blog` etc) have generic content that isn't tied to any country. And if at some point they do, it would change over time and never be a tied to any specific country. Hence, `/gb` isn't canonical for `/`. And for people outside of GB,AUS and UK I would want Google to serve `/` in the search results. I might very well be missing something obvious about this – Charklewis Jul 31 '20 at 15:12
  • Right, _Technically, the per language IRIs are canonical and alternate documents, depending on the language._ Your main issue is that you're using path-based language routing instead of relying on HTTP content negotiation. In other words, a URI should identify a unique resource. Different representations of that resource should be vended via content negotiation, not different URIs. See [When to use language negotiation](https://www.w3.org/International/questions/qa-when-lang-neg) for the trade-offs. – Rafael Aug 01 '20 at 01:37
  • 1
    Thanks for the tip. I think in our situation we will have each region URL as canonical, and provide alternates URLs (rather than the non-region as canonical). As you mentioned the per region IRIs are technically both canonical and alternate documents. Our situation is very similar to apple.com, and this seems to be the approach they are following also. – Charklewis Aug 01 '20 at 20:54