// Free Tool · Technical SEO

Hreflang Tag Generator

Generate valid hreflang link tags for every language and region version of your page, then copy the full reciprocal set in seconds.

International SEO

Hreflang Tag Generator

Add each language/region version of your page, get the full reciprocal set of hreflang tags

Page versions
Language = ISO 639-1 two-letter code (en, de, fr). Region is optional = ISO 3166-1 alpha-2 country code (us, gb, mx). Both are lowercased automatically.

x-default
The page Google serves when no language/region version matches the user. Usually your global or English-language homepage.
Waiting for input
Quick presets

What is a hreflang tag generator?

A hreflang tag generator is a free tool that builds the <link rel="alternate" hreflang="..."> tags that tell Google which language and region version of a page to serve to which user. Each tag pairs a language code with a page URL — the language is an ISO 639-1 two-letter code (such as en or de), optionally followed by an ISO 3166-1 alpha-2 region code (such as en-us or en-gb), all in lowercase by Google’s convention. The tool also adds an hreflang="x-default" tag for users whose language does not match any version. A correct hreflang set must be reciprocal and self-referential — every version lists every other version, including itself. This generator produces that full set for you, and it runs 100% in your browser, so nothing you type is ever sent to a server.

How to Generate Hreflang Tags: Step by Step

Hreflang annotations let you target the right language and region without creating duplicate-content problems between near-identical pages. Here is how to build a valid set.

1

Add Every Version of the Page

Click "Add version" and enter the full URL of each language or region variant of the same page. Add one row per version — for example, your English page, your German page, and your French page.

Tip: Use absolute URLs (starting with https://) and the canonical address of each version. Hreflang and canonical tags should point at the same URL for each page.
2

Set the Language and Region Codes

For each version, enter the language as a two-letter ISO 639-1 code, and optionally a region as a two-letter ISO 3166-1 alpha-2 country code. The tool lowercases both and joins them as language-region, for example en-gb. Use language alone (en) to target a language regardless of country.

Tip: The region is a country code, not a language. The United Kingdom is gb, not uk — the tool warns you if you enter uk.
3

Add an x-default URL

Enter the URL Google should serve when no language or region version matches the visitor — usually your global or English-language homepage. This becomes the hreflang="x-default" tag. It is optional but strongly recommended.

4

Review the Validation Notices

The tool checks for common mistakes as you type — an invalid or empty language code, the uk/gb mix-up, or a duplicate language-region pair. Fix any warnings before you publish, because an invalid entry is ignored and the affected version may not be served correctly.

5

Copy the Tags onto Every Page

Click "Copy" and place the full block in the <head> of every version listed — the set must be reciprocal and self-referential, so each page carries the same tags including a link to itself. You can also serve the same set in your XML sitemap or HTTP headers instead.

Tip: Use one method only — either HTML head tags, sitemap annotations, or HTTP headers — and keep the set identical on every page. Mixing methods or omitting the self-reference is the most common cause of hreflang errors.

The canonical conflict that silently disables hreflang

Correct tags on every page still produce nothing if the canonical works against them. The two annotations answer different questions, and confusing them is the failure that survives every other check:

Point the canonical of your German page at the English URL and you have told Google the German page is a duplicate that should not be indexed on its own. A URL removed from the index that way cannot be served as anyone's language match, so the hreflang set built around it stops working — while every tag in it still validates.

The rule that keeps the two compatible: every language version carries a canonical pointing at itself, and hreflang handles the relationship between versions. Canonical is for genuine duplicates within one language — a printer-friendly view, a tracking-parameter variant — not for translations.

Fast check: open the German page's source and confirm the canonical URL is the German URL. If it names any other language, that page is out of the running before hreflang is ever consulted.

Confirming Googlebot actually sees the tags

The DevTools element inspector shows the DOM after JavaScript has run, which makes tags injected by a script look identical to tags served in the HTML. They are not equivalent in practice: annotations that appear only after client-side rendering are far less reliable than ones present in the initial response.

Check the raw response instead:

When the block outgrows the head

Hreflang scales multiplicatively, which surprises people at the second or third rollout. Every version must list every other version plus itself, so the annotation count per page equals the number of versions, and across the site it is that number squared:

Language versionsTags per pageAnnotations site-wide, per page set
339
1010100
2525625

At three or four versions the head is the simplest place for them. Past roughly ten, the block starts to dominate the head of every page and any change means editing every template. That is the point to move the annotations into the XML sitemap, where the whole set lives in one file and a new language is one edit rather than a site-wide deployment. The requirements do not change — reciprocity and self-reference still apply — only the delivery method does.

What hreflang does not do

Frequently Asked Questions

What is a hreflang tag?
A hreflang tag is a <link rel="alternate" hreflang="..."> annotation that tells search engines which language and region a given URL is intended for. It lets you show searchers the version of a page that matches their language or country, and it prevents near-identical translated or localized pages from competing with each other as duplicate content. Hreflang is supported by Google; other search engines handle language targeting differently.
What format should the hreflang value use?
The value is a language code, optionally followed by a region code, in the form language-region. The language is an ISO 639-1 two-letter code such as en, de, or fr. The optional region is an ISO 3166-1 alpha-2 country code such as us, gb, or mx. So en-gb means English as used in the United Kingdom. Codes are case-insensitive, but Google’s convention is lowercase. The special value x-default marks the fallback page for unmatched users.
Do hreflang tags need to be reciprocal?
Yes. Hreflang annotations must be reciprocal and self-referential. If page A lists page B as an alternate, page B must list page A in return, and every page must also include a link to itself. If the return tag is missing, search engines may ignore the annotation entirely. That is why this tool outputs the complete set — you place the same block on every version of the page, including a self-referencing tag.
Should I use uk or gb for the United Kingdom?
Use gb. The region part of a hreflang value is an ISO 3166-1 alpha-2 country code, and the code for the United Kingdom is GB, not UK. Writing en-uk is one of the most common hreflang mistakes — it is invalid and is ignored. The correct value for British English is en-gb. This tool flags uk automatically so you can correct it.
Where do I put hreflang tags?
You can implement hreflang in one of three places: as <link> tags in the HTML <head> of each page, as annotations in your XML sitemap, or as HTTP Link headers (useful for non-HTML files such as PDFs). Pick one method and use it consistently — do not mix methods for the same set. Whatever method you choose, the full set of alternates must appear for every version of the page.
What is the x-default hreflang value?
The x-default value marks the page a search engine should serve when none of your language or region versions matches the user’s settings. It is typically a language selector page or your global or English-language homepage. While optional, including x-default is recommended because it gives Google a clear fallback instead of guessing, which improves how international users are routed to your content.
Can I use hreflang and canonical tags together?
Yes, and you should — but each language version must carry a canonical pointing at itself. The two answer different questions: hreflang says these pages are equivalents for different languages, while canonical says these URLs are the same page and only one should be indexed. Pointing the canonical of a German page at the English URL marks the German page as a duplicate that should not be indexed, so it can no longer be served as anyone's language match and the hreflang set around it stops working, even though every tag still validates.
How many hreflang tags do I need?
Every version must list every other version plus itself, so the number of tags on each page equals the number of language versions you have. Ten versions means ten tags on each of the ten pages. At three or four versions the HTML head is the simplest place for them; past roughly ten the block dominates every page and each change means editing every template, which is the point to move the annotations into your XML sitemap instead. The reciprocity and self-reference requirements are the same either way.

More free tools: browse the full catalog →