HomeToolsSEOhreflang generator
hreflang generator and checker
List the language versions of a page and the tool builds a complete reciprocal set in three formats: tags for <head>, an XML sitemap and an HTTP header. The checker tab finds mistakes in existing markup: en_US instead of en-US, en-UK, relative URLs, duplicates.
—
HTML — in the <head> of every version
XML sitemap
HTTP header — for PDFs and other non-HTML files
Pick one method. Tags, sitemap and header are equivalent for Google; there is no need to duplicate markup, and mismatches between methods only confuse search engines.
—
| Line | hreflang | URL | Status |
|---|
Everything is calculated in your browser — nothing you enter is sent anywhere.
How to use it
- Describe the structureEnter the domain, page path and where versions live — subfolders or subdomains. Pick a language set or add rows by hand.
- Check codes and URLsThe tool flags en_US, en-UK, country codes without a language, duplicates and relative URLs, and suggests the right value.
- Copy one formatTags go in the <head> of every version, the sitemap in your sitemap file, the HTTP header for PDFs and other files. The set is identical for all versions.
- Check a live pagePaste its HTML in “Check a page”: the tool extracts the links, finds errors and moves a corrected set to the generator.
What hreflang is and why you need it
hreflang tells search engines that a page has versions in other languages or for other countries. Google uses these links to show each user the right version: a German speaker gets /de/preise, an English speaker /pricing. It is not a ranking factor as such: it helps choose which URL to show.
Google supports three equivalent markup methods:
The attribute value is an ISO 639-1 language code, optionally followed by an ISO 3166-1 alpha-2 country code after a hyphen: en, en-GB, pt-BR. The special value x-default marks the page for everyone else: a language selector or the main version.
A single-language site does not need hreflang. You need it when the same page exists in several variants: translations, regional versions with different prices and currencies, same-language sites for different countries.
How to implement hreflang correctly
Reciprocity and self-reference
The key rule in Google’s documentation: links must be reciprocal. If the German version points to the English one, the English version must point back to the German; otherwise the markup may be ignored. Each version also lists itself. The simplest approach is to place the same complete set on every version — exactly what the generator builds.
Codes
- A language is always required; a country only together with a language.
hreflang="BE"is an error — usenl-BEorfr-BE. - The separator is a hyphen.
en_USappears in software locales, but in hreflang the correct form isen-US. - The United Kingdom is
GB, notUK:ukis the code for Ukrainian. - A language without a region acts as the fallback for all countries. If you have
en-GBanden-US, addenfor English speakers elsewhere.
hreflang and canonical
Each language version must be canonical to itself. A common mistake is pointing rel="canonical" on all translations to the English page: that declares translations duplicates, and search engines may not show them. Canonical points to the page in the same language; hreflang describes the relationship between languages. URLs in hreflang must match canonical URLs: no extra parameters, same protocol and trailing slash.
URLs
Use full URLs with protocol and domain: https://example.com/de/, not /de/. Versions can live on different domains — hreflang works across domains. Pages in the set must return 200 and must not be blocked from indexing.
Multilingual site structure and choosing URLs
Google relies on hreflang. Bing has historically recommended the HTML lang attribute or the content-language meta tag and a clear URL structure, and gives hreflang less weight. In practice, set both the lang attribute and hreflang.
Country domains, subdomains or subfolders
Google’s guide to multi-regional and multilingual sites compares the options like this:
- Country-code domains (
example.de,example.fr) — the clearest country signal, but each domain must be bought, maintained and grown separately. - Subdomains (
de.example.com) — easy to host separately; the link to the main site is less obvious to users. - Subfolders (
example.com/de/) — the easiest to maintain: one host, shared domain history. For SaaS usually the most practical choice. - URL parameters (
?lang=de) are not recommended by Google: they make it hard to tell which version a user sees.
Whichever option you choose, do not redirect users automatically by IP or browser language. Crawlers may never see the other versions, and people may not reach the one they wanted. Show a visible language switcher and let hreflang point search engines to the right URL.
Common hreflang mistakes
- No return links. Markup was added only to the main version — translations do not link back.
- No self-reference. The page lists every version except itself.
- Invalid codes:
en_US,en-UK,jpinstead ofja, three-letter codes likeeng, a country without a language. - Relative URLs, or URLs with tracking parameters or #fragments.
- Canonical to another language. Translations are declared duplicates of the main version.
- Versions blocked from indexing in robots.txt or with noindex — the link points to a page the search engine cannot use.
- One code, two URLs. Two different URLs with
hreflang="en"in one set. - Untranslated pages. A German version with English text is a duplicate, not a language version.
- Markup in several places that disagrees: one set in HTML, another in the sitemap.
Sources
- Google Search Central. Tell Google about localized versions of your page — developers.google.com/search/docs/specialty/international/localized-versions.
- Google Search Central. Managing multi-regional and multilingual sites — developers.google.com/search/docs/specialty/international/managing-multi-regional-sites.
- ISO 639-1:2002. Codes for the representation of names of languages — Part 1: Alpha-2 code; registry — loc.gov/standards/iso639-2.
- ISO 3166-1. Codes for the representation of names of countries — iso.org/iso-3166-country-codes.html.
- RFC 5646 (BCP 47). Tags for Identifying Languages. IETF, 2009.
- Sitemaps.org. Sitemap protocol — sitemaps.org/protocol.html.
- Bing Webmaster Blog. How to optimize your content for search in multiple languages and regions — blogs.bing.com/webmaster.
FAQ
How do I implement hreflang?
On every language version, add the full set of link rel="alternate" tags with hreflang: to all versions including the page itself, optionally with x-default. The code is an ISO 639-1 language, optionally with an ISO 3166-1 country after a hyphen; URLs must be absolute. The generator builds this set automatically.
What is x-default in hreflang?
The value for users whose language or country matches none of the versions. x-default usually points to a language selector or the main version. It is optional but recommended by Google.
Is it en-UK or en-GB?
en-GB. hreflang uses ISO 3166-1 country codes, and the United Kingdom’s code is GB. uk is the code for Ukrainian, so en-UK is an error.
Can I specify only a country, like hreflang="US"?
No. The language is required and the country is appended with a hyphen. hreflang="en" means English; for an English version aimed at the US, use en-US.
Should hreflang go in HTML or the sitemap?
Google treats the methods as equivalent. Head tags suit small sites, sitemaps suit large ones where you do not want to weigh down every page, and the HTTP header suits PDFs and other non-HTML files. Pick one method and avoid mismatches.
Do I need canonical together with hreflang?
Yes, but each language version must be canonical to itself. A canonical from a translation to the main version tells search engines the translation is a duplicate and keeps it from being shown.
Is hreflang enough for Bing?
Not on its own. Bing has historically recommended the HTML lang attribute or the content-language meta tag and gives hreflang less weight than Google does. Set both lang and hreflang to cover both search engines.
More in SEO
- SERP snippet preview
How will the title and description look in Google, and will they be cut off?
- Open Graph generator
Which Open Graph tags does the page need, and how will the link preview look?
- Readability checker
How hard is this text to read, and which sentences are too long?
- robots.txt generator and tester
Which robots.txt rules block or allow this URL for a given crawler?
- UTM builder
How do I build consistent UTM links for every campaign and channel?
- UTM QR code generator
Which booth, flyer or poster brought visitors — and how do I tag a QR code for each one?