translate Technical SEO

Hreflang Tag Generator: Build Markup From Your Language-URL Pairs

This hreflang generator builds markup from the language-URL pairs you type in. Add each page version with its language or language-region code and its full absolute URL, then export the cluster in the format you plan to ship: HTML link tags for the head, an HTTP Link header example, or XML sitemap xhtml:link entries. Every exported set includes a self-referencing tag and the matching return tags, so each page in the cluster points to all the others. Choose one method per cluster and stick with it. Once the markup is live, run the URL through our hreflang checker to confirm the deployed pages actually emit it.

build_circle Try the free tool

How it works

  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 you get

  • Language-region code check

  • Absolute URL check

    Every row needs a full URL beginning with http:// or https://.

  • Duplicate code detection

    Codes are compared without regard to case, so en-GB and en-gb count as the same entry.

  • x-default selection

Who it's for

  • International SEOs setting up regional English targeting.
  • Developers who need correct link tags or sitemap XML without hand-writing them.
  • Ecommerce teams running separate US, UK, Australian, and Singaporean storefronts.
  • Agency teams preparing hreflang specifications for client sites.

Good to know

Hreflang is a set of annotations, and every page in the set must list all the others and itself.

Get a Free Audit

How to generate hreflang markup from language-URL pairs

Start with one cluster: the set of pages that are translations or regional versions of the same content. In the generator, add one row per version. Each row needs a code, such as en, en-GB, fr-CA or ja, and the full absolute URL of that version, including https:// and the domain. If you have a global page or a country selector, add it as the x-default row. Then pick your export format and copy the output. The tool writes one alternate entry for every row, including the page itself, so the block is complete and bidirectional for that cluster. Repeat the process for each separate cluster rather than mixing unrelated pages into one set.

HTML head tags, HTTP Link header, or XML sitemap: which export to use

All three formats carry the same information, so choose the one that fits how the pages are served. HTML link tags in the head suit most normal websites where you control templates. The HTTP Link header export is for files that have no HTML head, such as PDFs or other downloadable documents, and is set at the server or CDN level. The XML sitemap export, using xhtml:link entries inside each url block, works well for large clusters or many locales, because it keeps the markup out of page templates and is easier to maintain in one place. Pick one method for a given cluster. Running HTML tags and sitemap entries side by side with different URLs or codes creates conflicting signals and makes debugging harder.

Mistakes to catch while you are generating, not after

Most hreflang errors are introduced at the moment the markup is written. Watch for invented codes like en-UK, which should be en-GB, or jp, which should be ja, since language codes follow ISO 639-1 and region codes follow ISO 3166-1 Alpha 2. A region on its own, such as GB, is not valid; it must follow a language. Enter absolute URLs only, because relative paths like /fr/ are not reliably resolved. Do not drop the current page from its own set. Finally, avoid copying the block from one page and pasting it onto a different page without replacing the URLs, which leaves the new page pointing at the wrong alternates and missing its own self reference.

After you paste the generated code: deploy, then validate

The generator produces correct markup from the pairs you enter, but it cannot see your live site. It does not confirm that each URL returns a 200 status, that every version actually ships the same block, or that canonical tags agree. After deployment, test each URL with the hreflang checker, which reads the live tags and reports missing return links and code errors. Hreflang helps search engines show the right regional version to the right users. It is not a ranking boost, and correct markup does not guarantee any position in any market.

Questions

Questions we get asked

Can I paste the same generated block on every page in the cluster?

Yes, for the HTML method. Because the export lists every version including the page itself, the identical block is valid on each page in that cluster. It is not valid on a different page with different content. A product page and a blog post need their own clusters, each generated from their own URLs.

What URL should I enter as x-default?

Use the page you want shown when no listed language or region matches the visitor, typically a country or language selector, or a global English page. Enter it as a full absolute URL like any other row. It can be the same URL as one of your language versions if that page doubles as the fallback.

Does the generator check that my URLs are live or indexable?

No. It builds markup from the pairs you provide and does not fetch the pages. Confirm the URLs return 200, are not blocked or noindexed, and are not canonicalized elsewhere, then validate the deployed tags with the hreflang checker.

How do I add hreflang to a PDF?

PDFs have no HTML head, so use the HTTP Link header export. Your server or CDN adds the header to the PDF response, listing each language version of the file with its code. The same rules apply: absolute URLs, a self reference, and matching headers on every version.

When is the sitemap export better than head tags?

When a cluster spans many locales or you have thousands of translated pages, the sitemap method keeps hreflang in one maintainable file instead of every template. Each url entry lists all alternates, including itself. Remember standard sitemap limits of 50,000 URLs and 50 MB uncompressed per file, and split into a sitemap index if you exceed them.

Free audit

Rolling out hreflang across a multilingual site?

Tell us about your locales and setup, and our team will help plan the implementation method, cluster structure, and validation process.

Get a Free Audit