Hreflang Generator
Generate the hreflang tags that tell Google which country or language version of a page to show.
Build valid hreflang annotations for US, UK, Australia, Singapore, and any other version of a page. Get HTML link tags or XML sitemap entries with x-default and self-references included.
Key takeaways
- check_circle Hreflang is a set of annotations, and every page in the set must list all the others and itself.
- check_circle British English is en-GB, not en-UK, and the region is always an ISO 3166-1 country code.
- check_circle Use either HTML link tags or sitemap entries for a given set, not both with conflicting data.
- check_circle Hreflang URLs should match each page's canonical URL and return a 200 status.
- check_circle Regional English pages need hreflang, local details, and self-referencing canonicals to be distinguished.
- check_circle The sitemap output is a complete urlset with the xhtml namespace, ready to save and submit.
- check_circle Hreflang targets the right version to the right user but does not directly raise rankings.
What is Hreflang Generator?
Hreflang Generator is a free tool that builds hreflang annotations for pages that exist in several language or regional versions. You enter a code and an absolute URL for each version, such as en-US, en-GB, en-AU, and en-SG, choose an x-default fallback, and the tool produces HTML link tags and XML sitemap entries you can paste into your site. A quick-fill button creates the four English regions from a single US URL, using the /uk/, /au/, and /sg/ folder convention.
Hreflang is an annotation that tells search engines which version of a page is meant for which language and country. It matters most when pages are similar, as with regional English sites. A US page and a UK page might differ only by spelling, currency, and phone number, so search engines can treat them as duplicates and show the wrong one. Hreflang links the versions together, so the right page appears for the right searcher.
The generator checks each code's shape, requires absolute URLs, flags duplicate codes, and reminds you when only one version is entered. It runs in your browser and sends nothing anywhere. It does not fetch your pages, confirm they return 200, or verify that a region code is a real country, so pair it with the Hreflang Checker after you publish. It is a builder, not an auditor.
Why hreflang matters
When several pages target the same language in different countries, search engines must guess which one to show. A wrong guess sends visitors to a page with the wrong currency, phone number, or shipping terms, which hurts conversion and trust. Correct hreflang removes the guesswork, and generating it from one source keeps every version consistent.
How to use this tool
- 1
Add each version
Enter a language-region code and the absolute URL for every version of the page.
- 2
Choose x-default
Pick the fallback page for visitors who match none of your versions.
- 3
Copy the tags
Paste the HTML into every version, or use the XML in your sitemap.
What this tool checks
Language-region code check
Each code is tested against the pattern language, optional script, optional region, such as en, en-GB, or zh-Hant-SG, plus x-default. Codes ending in -UK are rejected. Malformed codes are reported in a warning box before any output is produced.
Absolute URL check
Every row needs a full URL beginning with http:// or https://. Rows with a relative path, a missing URL, or a URL without a code are flagged and left out of the generated tags.
Duplicate code detection
Codes are compared without regard to case, so en-GB and en-gb count as the same entry. A repeated code is flagged because each hreflang value can point to only one URL per page.
x-default selection
The fallback menu is built from the URLs you have entered, so the x-default always points at one of your own pages. Leaving it on None simply omits the x-default line.
HTML link tags
Produces one link rel="alternate" tag per valid version, in the order entered, followed by the x-default tag. The same complete set belongs in the head of every version, including the page itself.
Sitemap XML entries
Builds a complete urlset with a url block for each valid version, a loc line, and the full set of xhtml:link alternates, x-default included. Two or more valid versions are required before any XML is generated.
Technical guide
Signals, standards, and what to fix when checks fail.
Valid codes and the en-UK trap
Adding the XML namespace
Canonicals and reciprocal sets
Deep dive
How hreflang works
Hreflang groups equivalent pages into a cluster and labels each with its language and, optionally, its country. When someone searches, the engine finds the cluster, then chooses the member that best fits the searcher's language and location, swapping the URL shown in results. Nothing is redirected and no page is removed from the index. The mechanism depends on trust between pages: each one must confirm the others, and each URL must be a legitimate, indexable page. If the confirmation is missing or one URL is broken, the engine can ignore the annotation for that pair. Hreflang is a hint like a canonical, so it can be overridden when other signals conflict. It is most valuable when versions are similar, and less critical for pages in clearly different languages.
Clusters, not pairs
Every page in a cluster lists every other page and itself. Adding a fifth region means updating all four existing pages, not only the new one. Automating the output prevents this drift.
Swapping, not redirecting
Hreflang changes which URL appears in results. It does not move users, so visitors who arrive from other routes still see the page they landed on. Users can still switch versions using your own navigation.
A hint, not a command
Search engines may still choose another version when signals conflict. Consistent canonicals, content, and links raise the odds they follow your annotations.
Regional English: US, UK, AU, SG
English-language sites often serve four markets with nearly identical copy. Hreflang labels them en-US, en-GB, en-AU, and en-SG, but the pages should also differ in ways searchers and engines can see. Use local spelling, such as color in the US and colour in the UK, Australia, and Singapore. Show local currency, such as USD, GBP, AUD, or SGD, and use local phone formats and addresses. Reference regional details like delivery areas, tax terms such as GST in Australia and Singapore, and local business directories. Without these differences, engines may fold the pages into one duplicate. The generator's quick-fill button assumes a folder structure of /uk/, /au/, and /sg/ under one domain. If you use separate country domains or subdomains, edit the URLs before copying.
Make pages genuinely local
Spelling, currency, phone numbers, addresses, and legal terms distinguish regional pages. Identical copy invites duplicate treatment even with valid hreflang in place. Local proof such as regional testimonials helps too.
Folder, subdomain, or domain
Folders under one domain are simplest to maintain. Separate country domains give stronger local signals but need their own hosting, links, and authority. Whichever you choose, keep the pattern consistent across every page.
Check the quick-fill assumption
The button builds /uk/, /au/, and /sg/ paths from a US URL. Change any row that does not match your real structure. The x-default is set to the US URL you enter.
HTML, header, or sitemap
Choosing where to place hreflang depends on scale and control. HTML link tags live in the head and are the easiest to inspect: view source and read them. They add weight to every page, so a set with many versions increases page size, and every template must output them correctly. Sitemap annotations keep pages clean and let one script maintain the full cluster, which suits catalogs with thousands of products. HTTP headers cover non-HTML files. Whichever you use, treat the annotation as generated data, not something typed by hand, because errors multiply with each added region. Store the mapping between versions in one source, such as a spreadsheet or database table, and generate tags from it so a change in one place updates every version.
When HTML tags fit
Use head tags for small sites and templates you control. They are visible in page source, so audits and debugging are quick. Keep the tags high in the head, ahead of heavy scripts.
When sitemaps fit
Use sitemap annotations for large catalogs. One generated file replaces thousands of head edits, though the xhtml namespace must be declared. Keep the sitemap free of redirected or noindexed URLs.
One source of truth
Keep the URL mapping in one table and generate output from it, so adding a region never requires editing pages by hand. Version the table so changes are traceable and reversible.
Testing and maintaining hreflang
After publishing, test every page in the set, not just one. The Hreflang Checker reads the HTML of a page you enter, validates codes, absolute URLs, self-reference, duplicates, and x-default, then fetches up to four alternates to confirm they link back. Run it from more than one version to cover a larger set. Use Google Search Console to watch for indexing issues on regional URLs. Retest after site migrations, URL changes, and template updates, because these break return links silently. Keep a log of each region's launch date and URL pattern. When you retire a region, remove its annotations from every remaining page, because references to dead URLs invalidate entries. A quarterly spot check is usually enough. Assign an owner so the checks actually happen.
Test the whole cluster
A set is only as strong as its weakest page. Run the checker from each version, since it examines return links for a limited number of alternates. Record the results for each region.
Retest after changes
Migrations, slug edits, and CMS updates commonly remove tags or change URLs. Recheck top pages after every release that touches templates. Add the check to your release checklist.
Retire regions cleanly
When a region closes, delete its entries from all other pages and redirect its URLs. Leftover annotations point at dead pages and weaken the set. Update the sitemap at the same time.
Examples
thumb_up Strong examples
Complete regional set
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/services/" /> A valid entry uses the correct en-GB code and a full https URL. The same set, with one such line per region, appears on every version so each page references all the others.
x-default fallback
<link rel="alternate" hreflang="x-default" href="https://example.com/services/" /> The fallback points to the main page for visitors outside the listed regions. It is a real, indexable URL that returns 200, and it also appears in the set on every version.
Sitemap entry with alternates
<xhtml:link rel="alternate" hreflang="en-AU" href="https://example.com/au/services/" /> Inside a url block, each alternate is an xhtml:link element. The block for every version repeats the same complete list, and the urlset declares the xhtml namespace.
thumb_down Weak examples
Invalid region code
<link rel="alternate" hreflang="en-UK" href="https://example.com/uk/services/" /> UK is not a region code. British English must be en-GB, so search engines may ignore this line and the UK page loses its regional signal.
Relative URL
<link rel="alternate" hreflang="en-SG" href="/sg/services/" /> Hreflang needs an absolute URL with protocol and domain. A relative path can resolve incorrectly, and the generator refuses to output it until it is fixed.
One-way annotation
US page lists en-GB, but the UK page has no hreflang tags Without a return link from the UK page, the pair is not confirmed. Search engines may ignore the annotation, so every version must carry the same complete set.
Best practices and common mistakes
check_circle Best practices
- done Enter every regional version, including the page you are editing, so each page carries a complete reciprocal set.
- done Use language-region codes such as en-US, en-GB, en-AU, and en-SG, and add a plain en only if you need a generic English fallback.
- done Point x-default at your main version or country selector page, not a redirecting URL.
- done Keep every hreflang URL identical to that page's canonical URL, including trailing slash and https.
- done Deploy the same block to every version, then confirm each page with the Hreflang Checker.
- done Regenerate the set whenever you add a region, retire a page, or change a URL structure.
cancel Common mistakes
- close Using uk, usa, or sg as a code instead of a proper language-region pair like en-GB.
- close Listing URLs that redirect, return errors, or carry a noindex tag.
- close Publishing the set on the UK page but forgetting the US, Australian, and Singaporean pages.
- close Canonicalizing regional pages to the US page while also declaring hreflang between them.
- close Combining HTML tags and sitemap annotations that disagree about the same URLs.
Common use cases
Launching /uk/, /au/, and /sg/ versions of a US service page and telling Google which audience each serves.
Adding hreflang to an ecommerce catalog where each product exists in several regional storefronts.
Generating sitemap annotations for a multi-region site so one file controls the whole cluster.
Fixing duplicate content between near-identical English pages aimed at different countries.
Documenting the correct hreflang set for developers before a template change or migration.
Who should use this
Glossary
- hreflang
- An annotation that identifies the language and optional country a page targets, and links it to its equivalent versions.
- x-default
- A reserved hreflang value marking the fallback page for users whose language or region matches none of the listed versions.
- Return link
- A reciprocal hreflang reference from an alternate page back to the original. Without it the pair may be ignored.
- ISO 639-1
- The two-letter language code standard used in hreflang values, such as en for English or fr for French.
- ISO 3166-1 alpha-2
- The two-letter country code standard used for the region part of a hreflang value, such as GB, AU, SG, or US.
- Self-reference
- A hreflang entry on a page that points to that same page, which is required for a valid set.
- Canonical URL
- The preferred address of a page. Hreflang URLs should match each page's own canonical, not another region's.
- XHTML namespace
- The XML namespace declaration required in a sitemap so that xhtml:link alternate elements are recognized.
Frequently asked questions
Ready for a deeper audit?
HeyLead reviews your site, competitors, and growth opportunities with no sales pressure.
Get a Free Audit arrow_forward