Why it matters
- Google uses
hreflangto show each searcher the version of a page for their language and country, such as the Saudi version to people searching from Saudi Arabia and the English one to people searching in English. - Google accepts ISO codes only and says that other codes, such as
es-419, are not supported. Google does not understand an invalid code, so that version may not be shown to the people it was made for. - Common mistakes on Gulf websites:
KSAinstead ofSA,UAEinstead ofAE,UKinstead ofGB, and underscores as inar_SA, which come from some software's locale settings.
Example
<link rel="alternate" hreflang="ar-KSA" href="https://example.com/sa/offers" /> <link rel="alternate" hreflang="ar_AE" href="https://example.com/ae/offers" /> <link rel="alternate" hreflang="en-UK" href="https://example.com/uk/offers" />
<link rel="alternate" hreflang="ar-SA" href="https://example.com/sa/offers" /> <link rel="alternate" hreflang="ar-AE" href="https://example.com/ae/offers" /> <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/offers" />
How to fix
Use a two-letter language code, then a two-letter country code when you target one country, joined by a hyphen:
html
<link rel="alternate" hreflang="ar-SA" href="https://example.com/sa/" />
<link rel="alternate" hreflang="ar-AE" href="https://example.com/ae/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />- Gulf country codes: Saudi Arabia
SA, UAEAE, OmanOM, KuwaitKW, BahrainBH, QatarQA. aralone means Arabic for every country, andx-defaultmarks the version shown when no other version fits the searcher.- Do not write a country code on its own:
SAalone is a language (Sanskrit), not Saudi Arabia.
How we detect
- We collect
hreflangvalues from<link rel="alternate">elements on the page and fromLinkheaders in the HTTP response. - We accept
x-default, or an ISO 639-1 language code, optionally followed by an ISO 15924 script code, then an ISO 3166-1 alpha-2 country code, in any letter case. - The code lists come from the IANA Language Subtag Registry; the country list holds only the officially assigned ISO 3166-1 codes.
- Each invalid code is its own finding, naming the part at fault and the correction when it is clear.
This rule does not yet check that the linked pages point back to each other; that needs the other pages to be fetched.