translate Technical SEO

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.

build_circle Try the free tool
star

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.
translate

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.

insights

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.

arrow_forward Wrong-country landings raise bounce rates and lose sales on pricing and delivery mismatches.
arrow_forward Regional English pages are near duplicates, so search engines need explicit signals to separate them.
arrow_forward One incorrect return link can invalidate the annotation for a whole pair of pages.
arrow_forward Hreflang mistakes are silent, so they persist for months unless someone audits them.
play_circle

How to use this tool

  1. 1

    Add each version

    Enter a language-region code and the absolute URL for every version of the page.

  2. 2

    Choose x-default

    Pick the fallback page for visitors who match none of your versions.

  3. 3

    Copy the tags

    Paste the HTML into every version, or use the XML in your sitemap.

fact_check

What this tool checks

verified

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.

verified

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.

verified

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.

verified

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.

verified

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.

verified

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.

engineering

Technical guide

Signals, standards, and what to fix when checks fail.

code

Three ways to declare hreflang

Google supports hreflang in three places: link tags in the HTML head, HTTP Link headers for non-HTML files such as PDFs, and XML sitemap entries. This tool produces the first and third. Use one method for a given set of pages, because mixing methods makes conflicts hard to trace. HTML tags suit small sites and templates you control. Sitemap entries suit large catalogs, because one file holds every annotation and can be regenerated by script. Whichever you pick, each URL in the set must carry the complete list of alternates, and each entry must include the page itself.
code

Valid codes and the en-UK trap

Hreflang values are a language in ISO 639-1 format, optionally followed by a region in ISO 3166-1 alpha-2 format. The United Kingdom is GB, so British English is en-GB, and en-UK is wrong. Australia is en-AU, Singapore is en-SG, and the United States is en-US. You can also use a language alone, such as en, or add a script for Chinese, like zh-Hant. The tool's pattern check catches malformed shapes and specifically rejects codes ending in -UK, because the United Kingdom is GB. It cannot know every valid ISO list entry, so still check unusual region codes against the official list before publishing.
code

Adding the XML namespace

The sitemap output is a complete urlset with the sitemap namespace and xmlns:xhtml="http://www.w3.org/1999/xhtml". Without the xhtml namespace, parsers reject the file. If you generate blocks for several pages, keep one urlset and paste additional url blocks inside it. Each urlset holds at most 50,000 URLs or 50 MB uncompressed, so very large sites split their annotations across several sitemap files. Validate the finished file in Search Console after submitting it. Compress large files with gzip if you like, but keep each file within the size limit.
code

Canonicals and reciprocal sets

Hreflang only works when each page in the set lists all the others and itself. If page A names page B but B does not name A, search engines can ignore that pair. Each page should also carry a self-referencing canonical, not a canonical pointing at another region. A canonical to the US version tells Google to treat the UK page as a duplicate, which cancels the hreflang. Every URL in the set should return 200, be indexable, and not be blocked by robots.txt. Generate the set once, then deploy the identical block to each version.
school

Deep dive

language

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.

public

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.

code

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.

rule

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.

compare

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.

rule

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.
lightbulb

Common use cases

task_alt

Launching /uk/, /au/, and /sg/ versions of a US service page and telling Google which audience each serves.

task_alt

Adding hreflang to an ecommerce catalog where each product exists in several regional storefronts.

task_alt

Generating sitemap annotations for a multi-region site so one file controls the whole cluster.

task_alt

Fixing duplicate content between near-identical English pages aimed at different countries.

task_alt

Documenting the correct hreflang set for developers before a template change or migration.

groups

Who should use this

person International SEOs setting up regional English targeting. person Developers who need correct link tags or sitemap XML without hand-writing them. person Ecommerce teams running separate US, UK, Australian, and Singaporean storefronts. person Agency teams preparing hreflang specifications for client sites. person Marketing managers launching a new country page and needing a checklist-ready output.
dictionary

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.
quiz

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