Hreflang Tag Generator
A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call
Free hreflang tag generator. Enter each language version of a page to get correct hreflang link tags, with invalid codes like en-UK caught.
- Valid versions
- 0
Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.
How to use the hreflang tag generator
Enter each language or regional version of one page on its own line: first the language code, then a space, then the full address of that version. For example:
en https://example.com/
en-GB https://example.com/uk/
de https://example.com/de/
x-default https://example.com/
The hreflang tag generator checks every code, fixes capitalization (so en-gb becomes en-GB), flags invalid codes and duplicates, and writes the full set of link tags, ready to copy. It also reminds you about x-default and about adding the same tags to every version.
It runs in your browser and doesn't upload anything.
What hreflang does
If your website has the same content in several languages, or versions for different countries, hreflang tells search engines which version is for whom. Google then shows the right version to the right searcher: the German page to people searching in German, the UK page to people in the UK, and so on.
Without hreflang, Google may still work it out, but it can show the wrong version, or treat near-identical regional pages (such as US and UK English versions) as duplicates and pick just one.
Hreflang doesn't make a page rank higher. It makes sure that when a page ranks, the right language or regional version appears.
The format
Each version gets a link tag in the <head> of the page:
<link rel="alternate" hreflang="en" href="https://example.com/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/">
<link rel="alternate" hreflang="de" href="https://example.com/de/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">
The value is a language code, optionally followed by a region code:
- Language: a two-letter ISO 639-1 code, such as
en(English),de(German),es(Spanish),fr(French),bn(Bengali),ar(Arabic),zh(Chinese),ja(Japanese). - Region (optional): a two-letter ISO 3166-1 alpha-2 country code, such as
GB,US,AU,DE,BD,IN. - Script (optional): a four-letter ISO 15924 code for languages written in more than one script, such as
zh-Hans(Simplified Chinese) orzh-Hant(Traditional Chinese).
You can't use a region on its own: hreflang="GB" isn't valid. A region always comes after a language.
The x-default value
x-default marks the page for visitors whose language or region you don't specifically list, often your main page or a language chooser. It's optional but recommended. The hreflang tag generator reminds you if it's missing.
The rules that trip people up
Use the right codes
The most common hreflang errors are invalid codes, and they make Google ignore the tags. The hreflang tag generator checks each code against the official ISO lists and catches the usual mistakes:
| Wrong | Right | Why |
|---|---|---|
| en-UK | en-GB | The United Kingdom's ISO code is GB |
| jp | ja | Japanese is "ja"; JP is the country |
| cn | zh or zh-CN | Chinese is "zh"; CN is the country |
| gr | el | Greek is "el"; GR is the country |
| dk | da | Danish is "da"; DK is the country |
| en-EU | en | EU isn't a country code |
Three codes are trickier, because they're valid but almost always typed by mistake. uk is Ukrainian, not the United Kingdom (use en-GB). se is Northern Sami, not Swedish (use sv). br is Breton, not Brazil (use pt-BR). The hreflang tag generator accepts these codes, since they are real languages, but shows a warning so you can check which one you meant.
Every version links to every version, including itself
If the English page lists the German page, the German page must list the English page back. These return links are how Google confirms the relationship. A page should also include a tag pointing to itself. The simplest approach: put the exact same set of tags on every version, which is what the generator gives you.
Use full, working addresses
Each href must be a full address including https://, pointing to a page that loads (not one that redirects or is blocked by robots.txt), and ideally the same address you use in your canonical tag. The meta tag generator creates canonical tags.
One page per code
Each language or language-region code should point to exactly one page. Listing en twice with different addresses is an error; the tool flags it.
Canonicals must agree
Each version should have a canonical tag pointing to itself, not to another language version. If the German page's canonical points to the English page, you're telling Google to ignore the German page, which contradicts the hreflang.
A worked example
A UK-based shop sells in the UK, the US and Germany. It has three versions of its delivery page:
https://example.com/uk/delivery/with prices in pounds and UK delivery times,https://example.com/us/delivery/with prices in dollars,https://example.com/de/delivery/in German, with prices in euros.
In the hreflang tag generator, the owner enters en-GB, en-US and de-DE with those addresses, plus x-default pointing to the US version as the fallback for everyone else. The tool returns four link tags. The same four tags go into the <head> of all three pages. Now a searcher in London sees the UK page, a searcher in Chicago the US page, and a searcher in Berlin the German page, and Google understands the two English pages aren't duplicates of each other but versions for different countries.
Notice the German page uses de-DE. If the shop also wanted to reach German speakers in Austria and Switzerland with the same page, plain de would cover German speakers everywhere.
Three ways to add hreflang
- In the HTML
<head>of each page, as link tags. This is what the hreflang tag generator produces and suits most sites. - In HTTP headers, useful for non-HTML files such as PDFs.
- In your XML sitemap, with
xhtml:linkelements for each URL. Large sites often prefer this because it keeps the tags in one place. Our XML sitemap generator creates a basic sitemap you can extend.
Use one method consistently; mixing them makes errors harder to find.
When you need hreflang, and when you don't
You need it when:
- you have the same content translated into several languages,
- you have versions for different countries in the same language (US and UK English, Spain and Mexico Spanish) with differences such as prices, currencies or spelling,
- you have a language chooser page you want shown to visitors from other regions.
You don't need it when:
- your site is in one language for one market,
- you have pages in different languages that aren't versions of the same content.
Small businesses serving one country usually don't need hreflang at all.
Checking it works
- Check the page source of each version to confirm the tags are there and identical.
- Test that every address loads with a 200 status, not a redirect.
- Search Console: the old International Targeting report has been retired, so use the URL Inspection tool and watch for "Alternate page with proper canonical tag" in the Pages report, which usually means Google has understood the versions.
- Crawling tools such as Screaming Frog can report missing return links across a whole site.
Moving or restructuring language versions
If you change where language versions live, for example from example.com/?lang=de to example.com/de/, set up 301 redirects from the old addresses, update every hreflang tag, and update your sitemap. Keep the old and new structures consistent during the change.
Search ads for the searches that matter now
Good markup helps your pages rank over time. Google Ads puts the same pages in front of buyers today. DeepRit manages Google Ads for small and mid-size businesses, and only Google Ads. We check your account before we ever get on a call, then fix the structure, the keywords, the tracking and the ads, with month-to-month terms and no long contract. Book a free audit call.
Frequently asked questions
What is an hreflang tag?
An hreflang tag is a link element that tells search engines which language and optional region a page is for, and where the other language or regional versions of the same page are.
What's the correct hreflang code for the UK?
en-GB. The country code for the United Kingdom is GB, so en-UK is invalid and is ignored by Google.
Do I need x-default?
It's optional but recommended. It tells search engines which page to show visitors whose language or region you don't target specifically.
Does every page need to link back?
Yes. Every version should list all the versions, including itself. Missing return links are one of the most common reasons hreflang is ignored.
Can hreflang improve my rankings?
Not directly. It helps the right language or regional version appear for each searcher, which improves the experience and can reduce duplicate-content confusion between similar regional pages.
Is the hreflang tag generator free?
Yes. It's free, needs no account, and runs entirely in your browser.
Free PPC audit
See where your ad budget leaks.
We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.