Hreflang Explained

The '''rel="alternate" hreflang="x"''' link attribute is a HTML meta element described in RFC 8288. Hreflang specifies the language and optional geographic restrictions for a document. Hreflang is interpreted by search engines and can be used by webmasters to clarify the lingual and geographical targeting of a website.

Purpose

Many websites are targeted at audience with different languages and localized for different countries. This can cause a lot of duplicate content or near duplicate content, as well as targeting issues with users from search engines.[1]

Search engines use hreflang to understand the lingual and geographical targeting of websites and use the information to show the right URL in search results, depending on user language and region preference.

There are 3 basic scenarios that can be covered with hreflang:

Hreflang attribute help your website deliver multiple variations of the website in different languages.[2]

Implementation

Hreflang can be implemented in 3 different ways.

The hreflang definition is done by creating a full set of all language and region specific versions of the same document. Every URL in the set must reference the full URL set. A self-reference is required, so the including document has to be always part of the URL set.[3]

Language and country codes

Hreflang accepts values that define languages ISO 639-1 and countries (ISO 3166-1). A language or a combination of language and region can be used as a value. A country-only value is not allowed.

Language Example
en
fr
be

Language and Region Example
fr-CA
en-CA
en-US

The value has to follow the standard in order to be used by search engines.

Language script variations

RFC 5646 allows language script variations as value for . Language script variations can directly be addressed using ISO 15924.

Examples
zh-Hant: Chinese (Traditional)
zh-Hans: Chinese (Simplified)

x-default

is a reserved value that can be used to specify a default version for a document. The x-default URL is not targeted at a specific region and/or language and is supposed to be shown to unspecified users. Google suggests defining an x-default version in each URL set, which will be shown to users from unspecified regions or languages in search results.[4] [5] Typically, in multilingual websites, the TLD (https://www.example.com) will get the x-default value in each URL set and the language folders/subdomains will be assigned hreflang values.

The URL that is defined as the x-default for a certain document, can also be specified for a certain language or language and region at the same time.

Markup examples

HTML

...

HTTP

HTTP/1.1 200 OKContent-Type: application/pdfLink: ; rel="alternate";hreflang="x-default", ; rel="alternate";hreflang="en-GB",; rel="alternate";hreflang="en-US"...

XML sitemaps

http://example.com/page.html http://us.example.com/page.html http://uk.example.com/page.html ...

Notes and References

  1. Web site: Versions localisées de vos pages Google Search Central Documentation . 2023-12-11 . Google for Developers.
  2. Web site: Shaikh . Gulammohiyuddin . 29 November 2021 . A Guide To Hreflang Tag Best Practices For SEO .
  3. Web site: Kulagin . Kirill . 13 December 2023 . List of Hreflang Country and Language Codes . KeyRealSeo. }
  4. Web site: Use hreflang for language and regional URLs . 2015-10-08 . Google Inc..
  5. Web site: Introducing "x-default hreflang" for international landing pages . 2015-10-08 . Google Webmaster Central Blog.