hreflang Tag Generator

Build hreflang tags for every language and region version of a page, with x-default, validation of duplicates, and output as HTML, HTTP header or sitemap XML.

Free. Runs in your browser. Nothing you paste is uploaded.

The fallback for users whose language and region match nothing above. Often the English or global version.
Updates as you type

How to use the hreflang generator

  1. Add one row per version of the page: choose the language, optionally the region, and paste that version’s full URL. Add rows for every language and market you serve.
  2. Keep x-default ticked and give it the URL of the version people should see when nothing matches, usually the global English page or a language selector.
  3. Pick the output format. HTML link tags go in the head of every version. The HTTP header form is for PDFs and other non-HTML files. The sitemap form is for sites that prefer to keep annotations out of templates.
  4. Copy the output and add it to every version of the page. That last point is the one most implementations get wrong: each page must carry the complete set, including a tag pointing to itself.

How hreflang works

hreflang tells Google that a set of URLs are the same content for different languages or regions, so it can show the right one to each searcher and not treat them as duplicates. Values are a language code (ISO 639-1, such as en or ur) optionally followed by a region (ISO 3166-1, such as PK or GB). “en-PK” means English for users in Pakistan; “en” alone means English anywhere. A region without a language, such as “PK”, is invalid.

The annotations must be reciprocal: if page A lists page B, page B must list page A. Google ignores one-way links because they are a common way for sites to claim other people’s pages. Every version should also reference itself. x-default marks the fallback and is not tied to a language.

When Pakistani sites need hreflang

  • Urdu and English versions of the same pages: en-PK and ur-PK, with x-default pointing to whichever is primary.
  • Exporters with market-specific pages, for example a surgical instruments manufacturer with en-GB, en-US and en-AE pages that differ in currency, contact details or compliance wording.
  • Diaspora audiences: an en-GB page for British Pakistanis and an en-PK page for domestic customers, when the offer genuinely differs.

hreflang does not help if the pages are identical except for the URL. Google will still pick one. It also does not translate anything or change rankings by itself; it routes users between versions you already have. The international SEO guide covers when separate versions are worth building.

Frequently asked questions

Do I need hreflang for a single-language site with one market?

No. hreflang only matters when there are alternate versions. A site that is entirely in English for Pakistan gains nothing from it.

Can I put hreflang in the sitemap instead of the page?

Yes. Google treats sitemap annotations and head tags equally. Sitemaps are easier to maintain for large sites; head tags are easier to verify page by page.

What is the difference between en-GB and en?

en-GB targets English speakers in the United Kingdom specifically. en targets English speakers everywhere. If you have both, the UK page is shown to UK searchers and the generic one to everyone else.

Related tools

Background reading: when hreflang is needed and how to structure multi-country sites, in the international SEO guide.


Click Here |