We respect your privacy.

We use strictly necessary cookies to keep you signed in and to protect against CSRF. With your permission we also use a small amount of first-party analytics to improve the product. We do not sell your data and we do not use third-party advertising trackers. See our cookie policy and privacy policy .

← All learn topics

Rule site.hreflang.invalid-lang-code

hreflang uses an invalid language or region code

site.hreflang.invalid-lang-code is a check in Crawlmind's site audit that grades medium-impact issues of this kind. This page explains why the rule matters and the exact fix.

Impact: mediumEffort: lowFixable: 1-click

Why it matters

The hreflang value must be a valid IETF BCP 47 language tag: a primary language subtag from ISO 639-1 (lowercase) optionally followed by an ISO 3166-1 alpha-2 region subtag (uppercase), separated by a hyphen. `EN-uk`, `en_GB`, `english`, `en-uk` (wrong region code) all silently fail validation and Google drops the entire hreflang cluster for the page.

The fix

Valid examples:

```html
<link rel="alternate" hreflang="en"    href="...">  <!-- any English -->
<link rel="alternate" hreflang="en-US" href="...">  <!-- US English -->
<link rel="alternate" hreflang="en-GB" href="...">  <!-- UK English -->
<link rel="alternate" hreflang="pt-BR" href="...">  <!-- Brazilian Portuguese -->
<link rel="alternate" hreflang="zh-Hans" href="...">  <!-- Simplified Chinese -->
<link rel="alternate" hreflang="x-default" href="...">  <!-- catch-all -->
```

Common mistakes:

| Wrong | Right | Reason |
|---|---|---|
| `en_GB` | `en-GB` | Hyphen, not underscore |
| `EN-gb` | `en-GB` | Language lowercase, region UPPER |
| `en-uk` | `en-GB` | UK is a country, GB is the ISO code |
| `zh-CN` | `zh-Hans` | Script subtag preferred over region for Chinese |
| `english` | `en` | Use the 2-letter code |

Validate with Google's Search Console international targeting report or [r12a.github.io/app-subtags](https://r12a.github.io/app-subtags/).

References