Hreflang is an HTML attribute that tells search engines a page has versions in other languages or for other regions. Google uses it to show the right version in each country's results, for example the UK English page to searchers in Britain and the Spanish page to searchers in Spain.
What hreflang looks like
Each version of the page lists all versions, including itself:
<link rel="alternate" hreflang="en-us" href="https://example.com/us/">
<link rel="alternate" hreflang="en-gb" href="https://example.com/uk/">
<link rel="alternate" hreflang="es" href="https://example.com/es/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">The language and region codes
- Language uses an ISO 639-1 code:
en,es,de,fr. - Region is optional and uses an ISO 3166-1 alpha-2 code:
us,gb,mx. - Combine them as language-region:
en-gb,es-mx. - A region alone isn't valid.
gbon its own doesn't work. And the UK isgb, notuk.