hreflang Tag Generator
Generate hreflang link tags for multilingual pages.
If you serve the same content in multiple languages or regions, you need hreflang tags to tell search engines “the other language versions of this page live here.” This generator takes a language code and URL per row and produces a block of <link rel="alternate"> tags you can paste straight into your page <head>.
Everything runs in your browser and nothing is sent to any server. Add an x-default row to point unmatched visitors at a fallback page, and the tool warns you if you enter the same code twice.
What hreflang is and when to use it
hreflang tells search engines about the language/region alternates of the same content. It helps show Korean speakers the Korean page and US-English speakers the en-US page, reducing duplicate content issues and serving localized results. Use a bare ISO 639-1 language code (ko, en, ja) or a language-region form (en-US, pt-BR, zh-Hant).
Reciprocal links are required
The most important rule is that hreflang must be reciprocal. If page A points to B as an alternate, page B must point back to A (and to the whole set, including itself). If only one side declares the relationship, search engines distrust and ignore the entire cluster. In practice the safest approach is to have every language version share the exact same hreflang block. That means each page's <head> contains:
- A
hreflanglink for every language version, including itself. - (Optional) one
x-defaultlink.
x-default and why absolute URLs
x-defaultmarks the fallback page for visitors who don't explicitly match any language/region. It usually points to a language-selection screen or a global English page. It is optional but recommended because it lets you control the unmatched experience.
Always use an absolute URL in href (a full address starting with https://). Relative paths do not work for hreflang, and each URL should match that page's canonical URL exactly — same protocol, domain, and trailing slash.
- Add one row per language/region with its code and absolute URL.
- Optionally add an
x-defaultrow for the fallback page. - Copy the generated
<link>block into the<head>of every version, identically.
After inserting it, use the SEO meta tag checkerto confirm each page's canonical and hreflang made it into the actual HTML as intended.
Codes people get wrong — correct value vs common mistake
hreflang values use ISO 639-1 for language and ISO 3166-1 alpha-2 for region. The most common error is treating a country name as a code. British English is en-GB, not en-UK, and Chinese is better expressed by script (Simplified/Traditional) than by region alone.
| Target | Correct value | Common mistake |
|---|---|---|
| Korean | ko or ko-KR | kr (kr is a country, not a language) |
| British English | en-GB | en-UK (UK is not an ISO code) |
| US English | en-US or en | us, en_US (no underscore) |
| Chinese (Simplified) | zh-Hans or zh-CN | cn, mixing zh-Hans-CN |
| Chinese (Traditional) | zh-Hant or zh-TW | tw, zh-Traditional |
| Brazilian Portuguese | pt-BR | br, pt-BZ |
| Language-agnostic fallback | x-default | default, xdefault |
Worked example — a three-language site
Say you have Korean, US-English, and Japanese versions plus a language-selection page. You enter these four rows: ko → https://example.com/ko/, en-US → https://example.com/en/, ja → https://example.com/ja/, x-default → https://example.com/. That produces this block:
<link rel="alternate" hreflang="ko" href="https://example.com/ko/" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en/" />
<link rel="alternate" hreflang="ja" href="https://example.com/ja/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />The key is that this exact same four-line block goes into the <head> of all three pages — /ko/, /en/, and /ja/ — verbatim. If each page lists only its own row, reciprocity breaks and the cluster is ignored.
Common pitfall
- Confusing country codes with language codes: Korean is
ko, notkr; British English isen-GB, noten-UK. An invalid code is dropped entirely. - Using an underscore separator: language-region pairs join with a hyphen only (
en-US). Writingen_USis invalid. - Pointing href at a redirecting or noindex page: every hreflang URL must return 200 and be an indexable canonical. If it 301s elsewhere or carries
noindex, that row won't be trusted.
Frequently asked questions
How do I write the hreflang code?
Do I have to include x-default?
Why should every page share the same block?
Can I use relative paths?
Are my URLs sent to a server?
Related guides
- Setting Up hreflang: Stop Multilingual SEO DuplicationConfigure hreflang correctly for multilingual sites and avoid the x-default and return-tag mistakes.