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.
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/).