Hreflang Tag Generator
Generate hreflang tags for every language and country version of a page. Pick a language and region for each URL, add an x-default, then copy the tags as HTML, XML sitemap entries or an HTTP header.
The fallback for everyone else. Usually your homepage or a language picker.
hreflang tags (HTML)
<!-- Add the URL of each version above to generate your tags -->
How to use the hreflang tag generator
1. Add each version of the page
Add one row for every language or country version of the page. Choose the language, add a region if the page targets one country, and paste the full URL. Include the page you’re working on as well: every version lists itself along with the others.
2. Set an x-default
The x-default is the fallback for visitors whose language or country you don’t target. Point it at your homepage, a global English page or a language picker.
3. Choose where the tags will go
Switch the output between HTML tags for the page’s <head>, entries for your XML sitemap, or an HTTP header for files like PDFs. One method is enough, so pick the one that’s easiest to keep up to date.
4. Add the same set to every version
Copy the same block of tags onto every page in the set. If the English page lists the German page, the German page has to list the English page too, or Google may ignore the tags.
What is hreflang?
Hreflang is an attribute that tells search engines which language and country a page is for, and where its other versions live. Google uses it to show the right version in each market, so Spanish speakers in Mexico land on your Mexican Spanish page instead of the US English one.
How hreflang codes work
A code starts with a two-letter language from ISO 639-1, like en or es. You can add a region from ISO 3166-1, like en-gb for English in the United Kingdom or es-mx for Spanish in Mexico. A region on its own, like gb, isn’t valid. For Chinese, you can also target a script: zh-hans for Simplified and zh-hant for Traditional.
What x-default does
x-default isn’t a language. It marks the page to show when none of your other versions match the searcher. Without it, Google picks the version it thinks fits best.
Hreflang in HTML, XML sitemaps and HTTP headers
HTML link tags
The most common method. Add the tags inside the <head> of every version:
<link rel="alternate" hreflang="en-us" href="https://example.com/" />
<link rel="alternate" hreflang="de" href="https://example.com/de/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />XML sitemap
Better for large sites, because the tags don’t add weight to every page. Each URL gets an entry listing all its versions, and the urlset needs the xmlns:xhtml namespace. The generator adds both for you.
HTTP headers
For files that have no <head>, like PDFs. Your server sends a Link header listing every version along with the file.
Common hreflang mistakes
Missing return links
Hreflang has to go both ways. If page A lists page B, page B must list page A. One-way annotations are the most common reason Google ignores hreflang.
Using uk for the United Kingdom
The region code for the United Kingdom is gb. uk is the language code for Ukrainian, so en-uk is invalid. The dropdowns in this tool only offer valid codes.
Pointing to URLs that redirect or aren’t indexable
Every URL in your hreflang set should return a 200 status, be indexable and be its own canonical. Links to redirects, noindexed pages or non-canonical URLs break the set.
Using relative URLs
Write https://example.com/de/, not /de/. Hreflang needs full URLs, including the protocol.
Frequently asked questions
Does hreflang help rankings?
Not directly. Hreflang doesn't make a page rank higher. It helps Google show searchers the version in their language or for their country, so a visitor in Germany sees your German page instead of the English one.
Do I need an x-default tag?
It isn't required, but it's recommended. x-default tells Google which page to show people whose language or country doesn't match any of your versions. Most sites point it at the homepage or a language picker.
Should hreflang codes be uppercase or lowercase?
Either works. Hreflang values aren't case-sensitive, so en-GB and en-gb mean the same thing. Just make sure the region code itself is right: the United Kingdom is gb, not uk.
Can a page have both hreflang and a canonical tag?
Yes. Each language version should have a canonical tag pointing to itself. Don't canonicalize your German page to the English one, or Google may drop the German page and ignore the hreflang.
Do I need hreflang if my site is in one language?
No. Hreflang is only for sites with the same content in more than one language or for more than one country. A single-language site doesn't need it.
Is anything I enter sent to a server?
No. The generator runs entirely in your browser. Your URLs never leave your device.
More free SEO tools
Robots.txt Generator
Build a robots.txt file with rules for search engines and AI crawlers like GPTBot and ClaudeBot.SERP Snippet Preview
See how your title and meta description look in Google, measured in pixels.Meta Tag Generator
Create title, description, robots, Open Graph and Twitter tags in one go.Schema Markup Generator
Generate valid JSON-LD for Organization, Article, Product, FAQ and more.