Hreflang tells search engines which URL to show for each language or region. Every version of a page lists itself and all its alternates with link rel="alternate" hreflang="code" and a full URL. Codes are an ISO 639-1 language, optionally followed by an ISO 3166-1 region such as en-GB, and x-default covers everyone else.
| Code | Valid? | Meaning |
|---|---|---|
| en | Yes | English, any region |
| en-GB | Yes | English for users in the United Kingdom |
| zh-Hant | Yes | Chinese in Traditional script (ISO 15924 script code) |
| es-419 | No (for Google) | Numeric regions are not supported |
| x-default | Yes | Fallback when no other version matches |
| GB | No | Region alone is not allowed |
| en-UK | No | The region code for the United Kingdom is GB |
Updated
Most hreflang problems are bookkeeping: one page forgets to link back, a code uses the wrong region, or URLs are relative. The generator below builds the full, symmetrical set for every version at once, so each page carries the same complete list.
Add each version's code and full URL. The generator checks the codes and writes the tag set and sitemap block for all versions at once.
The same five lines go on the English, British English, German and selector pages.
<link rel="alternate" hreflang="en" href="https://example.com/en/pricing">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/pricing">
<link rel="alternate" hreflang="de" href="https://example.com/de/preise">
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing">Sent by the server with the file, since a PDF has no head to put tags in.
Link: <https://example.com/en/guide.pdf>; rel="alternate"; hreflang="en",
<https://example.com/de/guide.pdf>; rel="alternate"; hreflang="de"Each url element lists every version, including itself. The xhtml namespace must be declared on urlset.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/en/pricing</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/pricing"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/preise"/>
</url>
<url>
<loc>https://example.com/de/preise</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/pricing"/>
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/de/preise"/>
</url>
</urlset>| Problem | Fix |
|---|---|
| Missing return link | Add the full set of tags to every version |
| Region without language, such as hreflang="US" | Use a language plus region, such as en-US |
| Wrong region code, such as en-UK | Use the ISO 3166-1 code GB |
| Relative href | Write the full URL with https and host |
| Alternate URL redirects or returns 404 | List only live, final URLs |
Use it when the same content exists in more than one language, or in one language with real regional differences such as prices, spelling or delivery terms. It helps Google send a searcher in Mexico to the Mexican Spanish page instead of the Spanish one from Spain.
A site in one language for one market does not need hreflang. Adding it there only creates something else to maintain.
Relative URLs are not accepted; the href must include https and the host. Underscores are wrong in hreflang: write en-GB, not en_GB, which is the Open Graph locale style.
Listing a URL that redirects or returns an error wastes the annotation. Keep the set to live, final addresses and update it whenever a translated page is added or removed.
Yes. Google's documentation says each version should list itself as well as all the other versions. Without the self reference the set is incomplete.
x-default names the page to show when a searcher's language or region matches none of your listed versions. A language selector page or your international homepage is the usual choice.
Google requires the links to go both ways. If A points to B but B does not point back to A, the annotation can be ignored. Return links stop third parties from claiming to be an alternate of your page.
Google treats all three as equivalent. HTML tags suit most sites. HTTP Link headers are the option for PDFs and other non-HTML files. A sitemap keeps the markup out of your pages and is easier for large sites with many languages.
No. A region code on its own is invalid. To target Canada in English and French, use en-CA and fr-CA.
Related: Hreflang generator, Canonical tag checker, Sitemap and robots.txt examples, Next.js SEO checklist, Open Graph tags explained.
Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.
We.Inc is an AI-powered website builder you can resell under your own brand. Launch a branded client dashboard, bill on Stripe Connect, and deliver AI-generated websites in minutes. White-label plans start at $99 a month for 25 client sites, with a 7-day free trial and no per-site fees.