Technical SEO & Indexing • 13 min read

How to Use a Free Hreflang Generator to Create Hreflang Tags

Generate correct hreflang tags in minutes: add your language versions, set x-default, and copy HTML or XML sitemap markup with a free hreflang generator.

By SEO Free Editorial Team
Published: December 1, 2026
How to use a free hreflang generator — build correct hreflang tags with x-default, on SEO Free

If your website serves the same content in more than one language or region, you have a problem that no amount of good writing will solve on its own. Google has to decide which version of a page to show to which visitor, and without explicit instructions it will guess — and it will often guess wrong. An American visitor lands on the British English page, a Spanish speaker is sent to the English homepage, and the regional pages you built so carefully compete against each other in the search results instead of each serving its own audience.

Hreflang tags are the instructions that fix this. They are small pieces of markup that tell Google, in a standard format, "this page is the US English version, that page is the UK English version, and this one is the Spanish version for Spain." When the tags are correct and complete, Google can serve the right version to the right searcher. When they are wrong, incomplete, or inconsistent, Google simply ignores them.

Writing hreflang tags by hand is exactly the kind of fiddly work that invites mistakes: one wrong country code, one missing reciprocal link, one forgotten self-reference, and the whole cluster stops working. A free hreflang generator does the formatting for you. You enter your URLs and language-region pairs, and it produces a complete, correctly formatted set of tags — either as HTML link elements for your page headers or as an XML sitemap block. This guide walks through the tool step by step, explains the choices it asks you to make, and shows you how to check that your tags actually work once they are live.

What hreflang tags actually do

Hreflang is an annotation, not a directive. It does not force Google to do anything; it gives Google a clear signal about which version of a page belongs to which language and region, so the search engine can choose correctly. It is built on two standards: ISO 639-1 for language codes (two lowercase letters, such as en for English or es for Spanish) and ISO 3166-1 Alpha-2 for region codes (two uppercase letters, such as US or GB). The two are combined with a hyphen, so en-US means English for the United States and en-GB means English for the United Kingdom.

A complete hreflang set for a page has three properties that matter more than anything else. First, it is reciprocal: if page A points to page B, page B must point back to page A. Second, it is self-referential: every page must include a tag pointing to itself. Third, it includes an x-default entry, the fallback page shown to visitors whose language or region matches none of the listed versions — usually your global homepage or a language selector page.

Hreflang also solves a duplicate content worry. When you run English pages for the US, UK, Canada, and Australia, the content is nearly identical, and without hreflang Google may treat the versions as duplicates and pick one to show everywhere. With correct hreflang, Google understands they are targeted regional alternatives, not copies, and each version can rank in its own market.

How the free hreflang generator works

The generator on SEO Free builds complete, reciprocal tag sets from a simple form. It has three inputs and two output formats:

  • Base Canonical URL: the main URL of the page cluster — usually your default or global version of the page.
  • Language & Regional Variations: one row per version that exists, pairing a language-region code such as en-US, en-GB, es-ES, fr-FR, or de-DE with that version's full URL.
  • Include x-default: a checkbox that adds an x-default tag pointing to the base canonical URL, so unmatched visitors have a fallback.

When you click Generate, the tool produces the full annotation set in the format you choose: HTML <link> tags for the <head> of your pages, or a formatted XML sitemap hreflang block with one <xhtml:link> child per variant inside each <url> entry. A one-click copy button puts the result on your clipboard. The tool also supports multi-URL bulk generation, so you can build tags for a whole cluster of pages rather than one page at a time.

One honest limit to keep in mind: the generator produces the markup only. It cannot verify that your localized pages exist, return a 200 status, or are indexable. That verification is your job, and this guide covers it below.

How to use the hreflang generator, step by step

  1. List every version that actually exists. Before you open the tool, write down every language-region pair with a live page. If your shop has English pages for the US and UK and a Spanish page only for Spain, your matrix has three variants, not four. Generating a tag for a version that does not exist yet wastes the annotation and can make Google distrust the whole cluster. Confirm each localized URL returns a 200 status before you generate anything.
  2. Enter your base canonical URL. Open the free hreflang generator and paste the canonical URL of the page's default version into the Base Canonical URL field. This is usually the global version of the page, and it is also the URL the x-default tag will point to.
  3. Add your language and region variations. Add one row for every version in your matrix, including the base version itself. For each row, enter the correct code and the full URL of that version — for example, en-US with https://example.com/us/, en-GB with https://example.com/gb/, and es-ES with https://example.com/es/. Use the official codes: en-GB, not en-UK; the country code for the United Kingdom is GB, and using UK is one of the most common reasons hreflang is ignored.
  4. Turn on the x-default fallback. Check the "Include x-default tag pointing to Base Canonical URL" option. The x-default entry tells Google which page to serve when a visitor's language or region matches none of your versions, and it doubles as the destination for your global language selector page.
  5. Click Generate Hreflang Tags. The tool builds the complete set: one tag per variant plus the x-default entry, with every variant listed in every version's set so the annotations are reciprocal and self-referential by construction.
  6. Choose your output format and copy it. Pick HTML <link> tags if you will place the annotations in your page headers, or the XML sitemap block if you prefer to keep them in your sitemap. Use the one-click copy button to copy the whole block.
  7. Paste the code into every page in the set — or into your sitemap. If you chose HTML, paste the complete tag set into the <head> of every page in the variant cluster, making sure each page carries the full set including its own self-referencing entry. If you chose XML, add the block to your sitemap, with one <url> entry per variant and one <xhtml:link> child per version inside each entry. Do not mix the two methods for the same cluster: use one implementation, consistently, everywhere.
  8. Verify the tags are live. After a few days, open two or three variants in your browser, view the page source, and confirm the tags are present and identical across the whole cluster. Then check Google Search Console: URL Inspection shows whether Google detected the hreflang annotations, and the International Targeting report flags errors such as missing return tags.

HTML tags or XML sitemap blocks — which should you choose?

Both formats carry the same information, and Google accepts either. The right choice depends on the size of your site and how your pages are built.

HTML <link> tags are the better choice for small sites and for pages whose templates you control directly. Each page carries its own annotation set in the <head>, which makes it easy to check by viewing the source. The drawback is maintenance: every time a regional version launches or retires, you must update the tag set on every page in the cluster, and on a large site that means touching dozens of templates.

XML sitemap blocks are the better choice for large sites. The complete reciprocal set lives in a single file instead of being spread across many page templates, so adding or retiring a version means editing one file. It also keeps dozens of <link> tags out of every HTML page, which reduces page weight. The drawback is that the sitemap must stay in sync: if you launch a new regional version and forget to update the sitemap block, the new page has no annotations at all. If you use this route, validate the file afterwards with a sitemap validator before you submit it, because a single syntax error can invalidate the whole sitemap.

Whichever format you choose, keep it consistent. Pick one method per cluster and use it on every page in that cluster. Mixing HTML tags on some pages and sitemap blocks on others invites exactly the inconsistencies that make Google ignore hreflang.

Tips for hreflang that actually works

  • Build the variant matrix first. List every language-region pair with a live page before you generate anything, and confirm each URL returns 200. A tag pointing at a page that does not exist is worse than no tag at all.
  • Use language alone when the content is not regional. If your Spanish page serves all Spanish speakers worldwide, hreflang="es" is correct and complete — you do not need es-ES, es-MX, and es-AR unless you genuinely have separate regional versions.
  • Never use a country code without a language. hreflang="US" is invalid. It must always be a language, optionally followed by a region: en-US or es-US are valid; US alone is not.
  • Keep the canonical self-referential on every variant. Each localized page must have a canonical tag pointing to itself, never to the main English version. If a variant's canonical points to another language version, Google treats the canonical as authoritative, folds the page into the canonical version, and the hreflang annotations are effectively ignored.
  • Do not put hreflang on redirected or blocked URLs. Every URL in the set must be the final, indexable destination. A tag pointing to a URL that redirects, returns an error, or is blocked by robots.txt or a noindex directive breaks the reciprocal chain.
  • Retire variants cleanly. When a regional version is discontinued, remove its tags from every remaining page, delete its entries from your XML sitemap, and redirect the retired URL to the closest matching variant. Leaving one direction in place creates the classic "no return tag" error.
  • Let Google take its time. There is no instant effect. Google must re-crawl every page in the cluster before the annotations are trusted, which can take days or weeks depending on crawl frequency. Use URL Inspection to confirm the tags were detected rather than assuming they worked.

Common problems and how to fix them

"No return tag" errors in Search Console. This is the most common hreflang error, and it means page A points to page B, but page B does not point back. It almost always happens when tags are added by hand on one template and forgotten on another, or when a new version launches without updating the older pages. The fix is to regenerate the complete set with the generator and paste the identical set onto every page in the cluster, including the new one. Our guide to fixing hreflang errors walks through this and the other Search Console hreflang reports in detail.

Wrong country codes. Using en-UK instead of en-GB is the classic mistake — UK is not a valid ISO 3166-1 Alpha-2 code for the United Kingdom, GB is. Search engines ignore the entire directive set when the code is invalid, so one wrong code can silently disable hreflang for the whole cluster. The generator uses the standard codes, but double-check any code you type yourself.

Missing self-referential tags. Every page that contains hreflang tags must also include a tag pointing to itself. Omitting it triggers Search Console errors and can cause Google to ignore the rest of the set. The generator includes the self-reference automatically; if you edit the output by hand, do not delete that line.

Hreflang on redirected or non-canonical URLs. If a variant URL redirects to another page, or its canonical points elsewhere, Google follows the redirect or the canonical instead of the hreflang signal. Always generate tags for final URLs, and make sure each variant canonicalizes to itself.

Tags for versions that do not exist yet. Generating annotations for a planned regional page before it is published creates return-tag errors the moment Google crawls the live pages and finds the missing destination. Generate tags only for versions that are live and returning 200.

Stale sitemap blocks. When you use the XML sitemap format and launch a new regional version, the sitemap block must be updated at the same time as the launch. A forgotten update leaves the new version invisible to hreflang until someone notices — usually weeks later, in a Search Console report.

Frequently asked questions

Do I need hreflang if my site is in one language only?

Usually not. Hreflang matters when the same content exists in more than one language, or the same language in more than one region — for example, English pages for the US and UK. A single-language, single-region site has no alternate versions to annotate, so there is nothing for hreflang to do.

Can I use hreflang for language alone, without a country?

Yes. hreflang="es" targets all Spanish speakers worldwide, regardless of region. Add a region code only when you have genuinely separate regional versions, such as es-ES for Spain and es-MX for Mexico. Using language alone is simpler and avoids inventing regional versions that do not exist.

Does hreflang stop Google treating my regional pages as duplicate content?

Yes, that is one of its main jobs. Near-identical English pages for the US, UK, Canada, and Australia look like duplicates without annotation. With correct hreflang, Google understands they are targeted regional alternatives and each version can rank in its own market instead of one version winning everywhere.

How long does Google take to process new hreflang tags?

There is no instant effect. Google must re-crawl every page in the cluster before the annotations are trusted, which can take days or weeks depending on how often your pages are crawled. Check URL Inspection to confirm the tags were detected, and give the cluster at least a couple of weeks before judging the result.

Is the hreflang generator really free?

Yes. The generator on SEO Free is completely free, with instant in-browser generation and no signup. It produces both HTML and XML sitemap output, supports bulk multi-URL generation, and copies the result with one click.

Bottom line

Hreflang is one of the few technical SEO tasks where the cost of a mistake is total silence: a single wrong code, a missing return tag, or a canonical pointing at the wrong version, and Google ignores the whole set without telling you why beyond a terse Search Console error. That is exactly why generating the tags is better than writing them by hand. List your real variants, enter them in the generator, keep x-default switched on, choose one output format, and put the identical set on every page in the cluster. Then verify — view source on a few variants, check URL Inspection, and watch the International Targeting report. Done that way, hreflang quietly does its job: every visitor, in every language and region, lands on the version of your page that was made for them.

Validate Your Robots.txt Directives in Bulk

Test up to 100 paths simultaneously against your live or draft rules using our RFC 9309 compliant evaluation engine.

Open Bulk Robots.txt Tester

Related Technical Guides