Yoryantra
← Back to Tools

Hreflang Tag Generator

Build a complete alternate set for localized pages, check Google-oriented language and region codes, add x-default, and generate HTML, HTTP Link header, or sitemap markup.

Fix before using the output:
  • Row 1: language/locale and alternate URL are both required.
  • Row 2: language/locale and alternate URL are both required.
  • Row 3: language/locale and alternate URL are both required.
Implementation checks:
  • Add at least one complete language/URL pair to generate annotations.
  • Add the current page URL to check whether the entered set contains a self-reference.
  • Only the entered alternate set is checked locally. Reciprocal return links on live pages cannot be confirmed without fetching those pages, and no network requests are made here.

Generated hreflang Markup

Complete the alternate set to generate markup.

Hreflang Works as a Set, Not as a Tag You Add to One Page

The most important part of hreflang is the relationship between localized URLs. If an English page, an Indian-English page, and a German page are alternatives of the same content, each participating page should expose the relevant alternate set—including itself. A single correct-looking tag on only one page does not establish the complete relationship.

Google also expects return links. If one localized page points to another as an alternate, the other page should point back. The rows entered here can be checked for a local self-reference, but reciprocity on live pages cannot be proved without crawling them. Google documents the full relationship rules in its localized-versions guidance.

Three Localized Pages in One Alternate Set

en → a general English page.

en-IN → English content adapted for India.

de → German content.

x-default → a language selector or neutral fallback for users who do not match another target.

The same complete alternate set should normally appear on each corresponding version. The URL paths do not have to use the language code, and alternate URLs can live on different domains.

Language, Region, and Script Are Different Signals

The first hreflang segment identifies the language, such as en, de, or hi. An optional two-letter region can narrow the audience, such as en-IN or en-GB. A region cannot stand alone because IN tells Google a country, not what language the page is written in.

Script codes are useful when the writing system matters, for example zh-Hans and zh-Hant. They can also be combined with a region where that level of targeting is genuinely needed. Script identifiers come from the ISO 15924 registry maintained by Unicode.

UK, EU, and “Looks Plausible” Are Common Code Traps

Google expects assigned ISO 3166-1 alpha-2 region codes. The United Kingdom is GB, not UK. Reserved or non-country values such as EU and UN do not work as normal hreflang regions. A code can look syntactically neat and still be ignored if it is not an assigned value Google supports.

Choose One Implementation Method You Can Maintain Reliably

Google supports HTML <link> tags, HTTP Link headers, and XML sitemap annotations as equivalent ways to communicate localized alternates. Using all three does not create an SEO bonus; it creates three places where the sets can drift apart.

HTML is usually straightforward for ordinary web pages. HTTP headers are particularly useful for non-HTML resources such as PDFs. Sitemap annotations can be easier when a large multilingual site already generates sitemaps centrally.

Sitemap Mode Produces the Repeated Alternate Block on Purpose

A valid localized sitemap does not contain one free-floating list of alternate links. Each <url> entry has its own <loc> and repeats the complete set of <xhtml:link> alternates. The sitemap root also needs the XHTML namespace.

The generated sitemap output is therefore an alternate-link block, not a complete sitemap. Place the same block inside every corresponding URL entry produced by your sitemap system.

Hreflang and Canonical Tags Solve Different Problems

Hreflang helps Google choose the appropriate language or regional version for a searcher. Canonicalization helps identify the representative URL among duplicate or near-duplicate pages. If regional pages are intended to remain independently searchable, carelessly canonicalizing every version to one country page can work against that goal.

Review canonical and hreflang signals together when localized pages have very similar content. A technically correct alternate set cannot compensate for contradictory indexing signals elsewhere on the page.

Before Publishing a Large Alternate Set

  • Use fully qualified http/https URLs, not relative paths.
  • Make sure every hreflang value maps to one intended alternate URL.
  • Include a self-reference on each participating localized page.
  • Check reciprocal links between alternate pages.
  • Consider a generic language catchall when several regional versions exist.
  • Use x-default when a neutral selector or fallback page is useful.
  • Keep the same set synchronized if your CMS or deployment process changes URLs.