The `hreflang` attribute is a highly specific signal that requires precise syntax to work correctly. Using an incorrect language or region code is like writing the wrong address on a letter—the message simply won’t be delivered. Search engines will ignore any `hreflang` tag that doesn’t use the proper standardized formats, which can invalidate your international targeting and lead to the wrong page being shown to users in search results.
This is a purely technical issue that often stems from simple typos or a misunderstanding of the required formats. The correct syntax is `language-region`, where the language is a two-letter ISO 639-1 code and the optional region is a two-letter ISO 3166-1 Alpha 2 code. Getting this right is fundamental to a successful localization strategy.

The ISO Standard: Getting the Codes Right
To ensure your `hreflang` tags are valid, you must adhere to two specific standards:
- ISO 639-1: For the two-letter language code (e.g., `en` for English, `es` for Spanish).
- ISO 3166-1 Alpha 2: For the two-letter country code (e.g., `US` for the United States, `GB` for Great Britain, `MX` for Mexico).
Any deviation from these standards will result in an invalid tag. For a comprehensive guide on implementation, refer to Moz’s guide to hreflang.
Common Mistakes to Avoid
<!-- Incorrect: 'en-UK' is not a valid code --> <link rel="alternate" hreflang="en-UK" href="https://example.com/en-gb/" /> <!-- Correct: Use 'en-GB' for the United Kingdom --> <link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/" />
How to Find and Fix Invalid Hreflang Codes
Auditing your site for these specific errors is a straightforward process with the right tools.
- Crawl Your Site: Use an SEO audit tool like Creeper to extract all `hreflang` annotations from your site.
- Validate Against ISO Standards: Our tool will automatically validate every language and region code against the official ISO lists and flag any that are incorrect or malformed.
- Correct the Invalid Tags: Review the flagged errors and correct the codes in your HTML, HTTP headers, or XML sitemap. This is also a good time to check for other issues, like inconsistent return tags.
For Google’s official guidance, see their documentation on localized versions of your page.

Frequently Asked Questions
What is the most common hreflang code mistake?
One of the most common mistakes is using the wrong country code. For example, using `en-uk` for the United Kingdom is incorrect; the proper ISO 3166-1 Alpha 2 code is `gb`. Another common error is reversing the codes, like `US-en` instead of the correct `en-US` format.
What is x-default?
The `x-default` value is a special hreflang attribute that specifies the default or fallback page for users when no other language or regional version of your content matches their browser settings. It’s a critical best practice for any international website.
Where can I find a list of all valid codes?
You can find the official list of two-letter language codes on the ISO 639-1 registry. For country codes, refer to the ISO 3166-1 Alpha 2 standard.
Are you speaking Google’s language correctly? Start your Creeper audit today to find and fix all hreflang code errors.