๐ Hreflang Generator, Build Reciprocal Hreflang Tags Free
By Shihab Mia ยท Updated 2026-07-28
Use a language code (en), optionally with a region (en-GB). Each URL should be the absolute, canonical address of that version. Leave a row blank to skip it.
x-default points to the page shown when no other language fits the visitor. Often your homepage or a language picker. Leave the URL blank to omit it.
Add a language and URL to build your hreflang tags.
Hreflang tags tell search engines which language and regional version of a page to show each visitor. This generator turns a simple list of language-region codes and URLs into valid <link rel="alternate" hreflang="..."> tags, including an optional x-default entry. Add a row for each version, copy the output, and paste it into the <head> of every page in the set. Everything runs in your browser, so your URLs never leave your device.
What is the Hreflang Tag Generator?
Hreflang is an HTML attribute (and an equivalent sitemap or HTTP-header signal) that Google and Yandex use to serve the right language or regional URL in search results. A page about the same product in English, British English, and Spanish is three separate URLs, and without hreflang a search engine might show the wrong one to a user, or treat the near-duplicate pages as competing for the same query. Hreflang resolves this by mapping each URL to a language code (like es) or a language-region code (like en-GB), so the engine can match the page to the user's own language and location settings.
The value has two parts: a language in ISO 639-1 (two letters, such as en, es, de) and an optional region in ISO 3166-1 Alpha-2 (such as GB, US, MX) joined by a hyphen. The language comes first and is required, the region is optional and refines it. So en targets all English speakers, while en-GB targets English speakers in the United Kingdom specifically. A common mistake is using a country code on its own (using uk or gb instead of en-GB), which is invalid because the first subtag must be a language, and the United Kingdom's own country code is actually GB, not UK.
Two rules make or break an hreflang setup. First, the tags must be reciprocal: if page A links to page B with hreflang, page B must link back to page A, or search engines ignore the annotations entirely. Search Engine Land's analysis of international sites found that a large share of hreflang errors trace back to exactly this, missing or broken return links. Second, every page in the cluster should be self-referencing, meaning it includes an hreflang tag pointing to its own URL alongside the tags for its alternates. The special value x-default is not a language at all, it marks the fallback page (often a homepage or a language selector) shown when none of the listed languages matches the visitor.
There are three ways to implement hreflang, and a site should pick exactly one method, never mix them. HTML link tags in the <head> work well for small to mid-size sites. XML sitemap annotations using xhtml:link entries keep the page <head> lightweight and are the standard choice for large sites with many locale combinations, since updating one sitemap file is easier than editing thousands of pages. HTTP header annotations are for non-HTML resources such as PDFs or other downloadable files that have no <head> to put a link tag in. Google explicitly recommends against mixing methods on the same page set, since conflicting signals from different methods make the whole cluster harder to trust.
Hreflang and canonical tags serve different jobs and must stay consistent with each other. The canonical tag says "this is the preferred version of this specific page," and on a translated page the canonical should point to itself, not back to the original-language version. If a Spanish page's canonical points to the English original, it tells Google the Spanish page is a duplicate to be ignored, which cancels out any hreflang annotations pointing to it. This is one of the more common causes of hreflang tags getting silently dropped from search results even when the codes and reciprocal links are all correct.
Google has repeatedly said that incorrect hreflang does not get a page penalized, the tags are simply ignored and the page falls back to normal ranking signals. That makes hreflang a "soft" signal, but a valuable one for controlling which URL shows in which market, avoiding self-competition between near-duplicate localized pages, and reducing bounce rate from visitors landing on the wrong language version. After publishing tags, use Google Search Console's International Targeting report or the URL Inspection tool to confirm Google is actually reading them as intended, since a syntax error that looks fine to the eye can still make the whole group invalid.
When to use it
- Telling Google to serve the British English page to UK visitors and the US English page to American visitors instead of mixing them up.
- Stopping near-duplicate language versions of the same page from competing against each other in search results.
- Setting an x-default fallback so visitors whose language is not covered land on a sensible homepage or language picker.
- Generating the matching reciprocal tags for a small set of localized pages before pasting them into each page head.
- Building the xhtml:link block for an XML sitemap on a large multilingual site where per-page tags would be too much to maintain.
- Auditing an existing international page set by regenerating the tags from scratch and diffing them against what is currently live.
How to use the Hreflang Tag Generator
- Add a row for each language version: enter the code (en, en-GB, es-419) and that version's absolute URL.
- Use the + Add language button for as many versions as you have.
- Tick "Add an x-default entry" and enter the fallback URL if you want a catch-all version.
- Copy the generated tags and paste them into the <head> of every page in the set, then confirm each page links back to all the others.
- Verify the live result in Google Search Console (International Targeting report or URL Inspection tool) a few days after publishing.
Formula & method
Worked examples
A shop has one page in three versions: generic English, British English, and Spanish, with a homepage fallback.
- Add row 1: code en, URL https://example.com/
- Add row 2: code en-GB, URL https://example.com/en-gb/
- Add row 3: code es, URL https://example.com/es/
- Tick x-default and set its URL to https://example.com/
- Copy the four <link> lines into the <head> of all three pages.
Result: <link rel="alternate" hreflang="en" href="https://example.com/" />, <link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/" />, <link rel="alternate" hreflang="es" href="https://example.com/es/" />, <link rel="alternate" hreflang="x-default" href="https://example.com/" />
A regional rollout targets Spanish in Spain, Mexico, and Latin America generally.
- Add row 1: code es-ES, URL https://example.com/es-es/
- Add row 2: code es-MX, URL https://example.com/es-mx/
- Add row 3: code es-419 (Latin America), URL https://example.com/es-419/
- Each page must include all three tags plus a tag pointing to itself.
Result: Three reciprocal <link rel="alternate" hreflang="es-ES | es-MX | es-419"> tags, each present on every page in the cluster.
A large site with hundreds of localized product pages wants to avoid editing every page head, so it uses the sitemap method instead.
- Generate the same hreflang rows (en, de, fr, x-default) using the tool as normal.
- Instead of pasting <link> tags, convert each row into an xhtml:link entry inside the relevant <url> block of the XML sitemap.
- Repeat the same block of alternate links for every localized <url> entry describing that product, including the self-referencing one.
- Submit the updated sitemap in Google Search Console and confirm no <link rel="alternate"> tags remain in the page <head> to avoid mixing methods.
Result: A single sitemap file carries all reciprocal hreflang relationships for hundreds of URLs, with no per-page <head> edits required.
Common hreflang values and what they target
| hreflang value | Meaning |
|---|---|
| en | English, any region |
| en-US | English, United States |
| en-GB | English, United Kingdom |
| es | Spanish, any region |
| es-419 | Spanish, Latin America (UN M49 region code) |
| fr-CA | French, Canada |
| zh-Hans | Chinese, Simplified script |
| x-default | Fallback for unmatched languages or regions |
The three ways to declare hreflang (pick one method per page set)
| Method | Where it goes | Best for |
|---|---|---|
| HTML link tags | In the <head> of each page | Most sites and static pages |
| XML sitemap | xhtml:link entries in the sitemap | Large sites, keeps page <head> light |
| HTTP header | Link: header in the server response | Non-HTML files such as PDFs |
Codes that look right but are wrong
| Mistake | Why it fails | Correct form |
|---|---|---|
| uk (as a language) | uk is not a valid ISO 639-1 language, it actually maps to Ukrainian | en-GB |
| en_US (underscore) | Hreflang requires a hyphen separator, not an underscore | en-US |
| EN-us (wrong case) | Not strictly invalid, but inconsistent casing can confuse tooling and audits | en-US |
| es-LATAM | LATAM is not a real ISO 3166-1 or UN M49 code | es-419 |
Common mistakes to avoid
- Using a country code as the language. The first subtag must be a language (ISO 639-1), not a country. Writing hreflang="uk" targets Ukrainian, not the United Kingdom. For British English use hreflang="en-GB".
- Missing return (reciprocal) tags. If page A points to page B but B does not point back to A, search engines drop the annotation. Every page must link to every other version in the set, including itself. This is consistently cited as the single most common hreflang error.
- Forgetting the self-referencing tag. Each page should include an hreflang tag for its own URL. Listing only the other versions is incomplete and weakens the cluster.
- Using relative or non-canonical URLs. hreflang URLs must be absolute (starting with https://) and should point to the canonical, indexable version of each page, not a redirect or a noindex URL.
- Treating x-default as a language. x-default is a fallback marker, not a locale. Use it once for the page shown when no listed language matches, typically a homepage or a language selector.
- Letting the canonical tag point to a different language version. Each localized page should be self-canonical. If a translated page's canonical points back to the original-language page, it tells search engines the translation is a duplicate to ignore, which cancels out the hreflang signal even if the codes and reciprocal links are perfect.
Glossary
- hreflang
- An attribute that tells search engines the language and optional region a page targets, so they can serve the right version.
- rel="alternate"
- The link relationship that marks a URL as an alternate version of the current page, used together with hreflang.
- x-default
- A special hreflang value marking the fallback page shown when none of the listed language or region versions matches the visitor.
- ISO 639-1
- The two-letter language code standard (en, es, de) used for the first part of an hreflang value.
- ISO 3166-1 Alpha-2
- The two-letter country code standard (US, GB, MX) used for the optional region part of an hreflang value.
- Reciprocal (return) tags
- The requirement that every page in a language set links back to every other page, or search engines ignore the hreflang signals.
- xhtml:link
- The XML element used to declare hreflang alternates inside an XML sitemap instead of the page <head>, common on large multilingual sites.
- International Targeting report
- A Google Search Console report that shows how Google is actually reading a site's hreflang annotations, used to catch errors after publishing.
Frequently asked questions
What is an hreflang tag?
An hreflang tag is a <link rel="alternate" hreflang="..."> element that tells search engines which language and regional version of a page to show a given user. It connects the different language versions of the same content so Google and Yandex serve the right URL.
Do I need a region code, or is the language enough?
The language code alone is enough and is required (for example es). The region is optional and only needed when you have different content for the same language in different countries, such as en-GB versus en-US. Do not add a region unless the pages actually differ by country.
What does x-default do?
x-default marks the fallback page shown when none of your listed languages or regions matches the visitor. It is usually a homepage or a language-selector page. It is optional but recommended, and you use it once across the set.
Where do I put the generated tags?
Place the tags in the <head> section of every page in the language set. Each page must include the full set, including a tag pointing to its own URL, and every page must link back to all the others for the annotations to count.
Why are my hreflang tags being ignored?
The most common cause is missing return tags: if page A points to page B but B does not point back to A, search engines discard the annotation. Other causes are relative URLs, pointing to redirected or noindex pages, a canonical tag that points elsewhere, or using a country code where a language code belongs.
Does hreflang replace a canonical tag?
No. They work together. Each language version should be self-canonical (its canonical points to itself), while hreflang links the versions to each other. Pointing a canonical at a different language version cancels the hreflang signal, so keep them consistent.
Can I use hreflang in an XML sitemap instead of the page head?
Yes. Adding xhtml:link entries to your sitemap is a fully supported alternative to HTML link tags, and it is often easier to maintain on large sites since you edit one sitemap file instead of thousands of page heads. Pick one method (head tags, sitemap, or HTTP header) and do not mix them on the same page set.
Does incorrect hreflang get my site penalized?
No. Google has said repeatedly that broken hreflang is simply ignored, not penalized. The downside is missed opportunity, visitors can land on the wrong language version and near-duplicate pages can compete against each other in search results, but there is no ranking penalty for getting the syntax wrong.
How do I check whether Google actually sees my hreflang tags correctly?
Use the International Targeting report or the URL Inspection tool in Google Search Console a few days after publishing. Both show how Google parsed your annotations, which catches subtle problems like missing return links that look fine when you read the HTML yourself.
Should every page have hreflang, or only the localized ones?
Only include hreflang on pages that are meant to be indexed as part of the multilingual set. Adding it to a redirecting page, a noindex page, or a page that is not actually a translation of the others creates a conflict and can produce a "no return tag" error for the whole cluster.
Sources
- Tell Google about localized versions of your page , Google Search Central
- rel="alternate" hreflang="x" (BCP 47 language tags) , IETF / W3C
- What Is Hreflang? A Guide to Multilingual SEO Success , Search Engine Land