BV
All tools
seo

Hreflang Tag Generator

Build a complete, reciprocal hreflang set for a multilingual page and export it as link tags, an HTTP header block or XML sitemap entries. Validates language and region codes and adds x-default automatically.

Muhammad Bilal
Muhammad Bilal Virk
4 min read
Hreflang tag generator
Locales
3
Tags emitted
4
Problems found
1
Your x-default URL is not one of the listed alternates. That is allowed but unusual — check it is deliberate.
Head tags
<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/pricing" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/pricing" />
<link rel="alternate" hreflang="de" href="https://example.com/de/preise" />
<link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />
Hreflang has to be reciprocal. If the German page lists the English one, the English page must list the German one and itself, or Google discards the whole cluster. Every page in the set carries the same complete block, including a self-referencing entry — that is the single most common reason these tags get silently ignored.

Hreflang fails silently. A missing return link or an invented region code produces no error anywhere — the annotation is simply ignored. Enter your language versions and this generator produces a complete reciprocal set in whichever of the three valid formats you need.

What this tool does

Add each language or regional version of a page with its URL, and the generator produces the full annotation set. Because hreflang must be reciprocal — every page in the group has to reference every other page including itself — the output is a complete block you place on all of them, not a per-page fragment.

You get three output formats: <link rel="alternate"> tags for the head, Link: HTTP headers for non-HTML files such as PDFs, and <xhtml:link> entries for an XML sitemap. Codes are validated as you type, and x-default is offered for the fallback version.

A worked example

A page exists in British English, US English, French and Spanish, with a language selector at the root.

You enter five rows: en-GB, en-US, fr, es, and the root as x-default. The generator returns a five-line block. That exact block goes on all five pages, unchanged. If the French page carries only its own tag, or omits en-GB, the whole group is invalid and Google ignores it — which is the single most common hreflang failure.

Which format to use where

Format Use when
<link> tags in head Standard HTML pages, small numbers of variants
Link: HTTP header Non-HTML files, or when you cannot edit the head
Sitemap XML Many variants, or head bloat is a concern

Pick one. Google's localised versions documentation is explicit that mixing methods for the same page group causes conflicts.

Where people go wrong

Non-reciprocal tags. If page A points to page B, page B must point back to page A. Anything less and the annotation is discarded. This is the failure that generates the most "hreflang not working" support threads.

Region codes used as language codes. en-UK is not valid. The country is GB under ISO 3166-1 Alpha 2, so it is en-GB. Likewise the language for Japan is ja, not jp. The tool rejects both.

Region without language. hreflang="gb" is meaningless. The language subtag is compulsory; the region is optional and comes second.

Relative URLs. Every href must be absolute, including the scheme. Relative paths are ignored.

Pointing at non-canonical URLs. Each hreflang target should be that version's canonical URL, and each page's own canonical should point to itself. A canonical that points at the English version while hreflang points at the French one gives Google contradictory instructions, and the canonical wins. Google's guidance on consolidating duplicate URLs covers how the two interact.

Forgetting x-default. Not compulsory, but without it a visitor whose language matches nothing in your set gets whichever version Google guesses. Point x-default at your language selector or your most general version.

FAQ

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

No. It exists solely to tell search engines which of several equivalent pages to show a given user. One language, one region, no hreflang.

Does hreflang stop duplicate content penalties?

There is no duplicate content penalty to stop. What hreflang does is prevent your German page being shown to a British searcher and vice versa, which is a targeting problem rather than a penalty problem.

Can two versions share a language code?

Only with different regions. en-GB and en-US are fine. Two entries both reading en are a conflict, and Google will ignore the set.

Do I put the tags on every page or just the homepage?

Every page in the group, on every version, referencing every member including itself. Hreflang is annotated per page, not per site.

Is Bing the same?

Bing supports hreflang but leans more heavily on the content-language meta tag and on server geolocation. If Bing traffic matters to you, add both rather than choosing.

Next steps

Once the annotations are in place, make sure every variant is actually in your sitemap using the Sitemap Generator, and confirm the canonical tags agree with the canonical tag generator. The On-Page SEO Auditor will flag pages where the head is incomplete.

If you are managing content across markets by hand, API Automation for Businesses covers syncing the systems that hold it.

International rollout stalling on technical detail? Book a discovery call.

Muhammad Bilal
Muhammad Bilal Virk
AI automation engineer — building agents, workflows, and RPA that remove repetitive work.
Share
Newsletter

One email, when I ship something worth reading.

No cadence, no filler. Unsubscribe any time.

Free consultation

Want this built against your real numbers?

A 30-minute call to scope the workflow, agent, or automation you actually need.

Book a free consultation

More seo tools

All tools
Next step

Have a workflow that's burning hours every week?

Bring me one real bottleneck. I'll tell you whether it's worth automating, and what it would take.

Book 30 Minutes Call