Skip to content

Hreflang Generator

Add each language or region version of a page and get the complete set of hreflang link tags — validated against the real ISO 639-1 language list, not just a two-letter shape, with duplicate detection and an x-default reminder.

  • Validated against real ISO 639-1 codes
  • Language-region pairs (es-MX, pt-BR)
  • Duplicate code detection
  • x-default reminder
  • Runs fully client-side

Generator

Built in your browser, never sent anywhere

    Add at least two language versions to generate hreflang tags.

    How to generate hreflang tags

    1. 01

      Add each language version

      For every language or region version of the page, add its code (en, es, es-MX) and its full URL.

    2. 02

      Add an x-default entry

      This is the fallback shown to a visitor whose language does not match any of the listed versions — usually your default or English page.

    3. 03

      Fix anything flagged

      Unrecognized codes, duplicates and relative URLs are called out before you copy anything.

    4. 04

      Paste the same tags on every page in the set

      This is the part that trips people up: the identical block of tags needs to go on every URL in the group, including a tag pointing back at itself.

    Every page in the set needs the complete, identical tag block#

    This is the rule that breaks hreflang most often in practice: the tags are not something you put only on your default or English page. Every URL in the set — the English page, the Spanish page, the Mexican-Spanish page — needs the exact same block of tags, including a tag that points back at itself.

    Google describes this as a required "return link" — if your Spanish page links to your English page via hreflang, but the English page does not link back to the Spanish one, Google may ignore the annotations entirely rather than guess at what you meant.

    Why the language code has to be real#

    hreflang values are checked against ISO 639-1 for the language part and ISO 3166-1 Alpha 2 for the optional region — not just "two letters." A typo like xx or a made-up code fails silently: Google does not error out or notify you, it simply ignores that particular annotation, and the page it pointed to stops receiving the international targeting you intended.

    This tool validates every code against the actual ISO 639-1 list, not just a regex checking for two letters, specifically to catch that failure mode before it reaches production.

    Language versus language-region, and when you need both#

    A plain es targets every Spanish-reading visitor, everywhere. es-MX targets Spanish-reading visitors specifically in Mexico. You do not need to specify a region unless the content genuinely differs by region — pricing in local currency, region-specific promotions, or dialect differences worth serving separately.

    A common, correct pattern is a generic es page for Spanish-speaking visitors generally, plus es-MX and es-AR variants only where the content actually diverges — not a full region for every Spanish-speaking country by default.

    What x-default is for#

    x-default marks the page to show a visitor whose language does not match any of the versions you have listed — someone browsing in German when you only have English and Spanish versions, for instance. It is optional but recommended by Google's own documentation, and it is usually your default or English-language page.

    Without it, a visitor outside every language you have targeted gets Google's best guess instead of your explicit choice, which is worth being deliberate about rather than leaving to chance.

    Frequently asked questions

    Do I need to add hreflang tags to every page, or just one?

    Every page in the set needs the identical block of tags, including one pointing back at itself. Google calls this a required return link — if page A links to page B via hreflang but B does not link back to A, the annotation can be ignored entirely.

    What happens if I use an invalid language code?

    Google does not raise an error — it silently ignores that specific annotation. The page effectively loses its international targeting with no notification, which is why validating against the real ISO 639-1 list matters more than it might seem.

    What is x-default for?

    It is the fallback page shown to a visitor whose language does not match any of the versions you have listed. It is optional but recommended, and is usually your default or English-language page.

    Do I need a region code, like es-MX, or is es enough?

    Plain es is enough unless the content genuinely differs by region — pricing, promotions, or meaningful dialect differences. Adding a region to every language by default, without a reason, just adds more pages you have to keep in sync.

    Can hreflang point to a relative URL?

    No, it must be an absolute URL including the scheme, since search engines process hreflang independently of the page context. A relative path is treated as invalid and the annotation is skipped.

    Does this generate hreflang for my sitemap.xml, or for HTML link tags?

    HTML link tags — the <link rel="alternate" hreflang="..."> format that goes in a page's <head>. Hreflang annotations can alternatively be embedded inside an XML sitemap instead, which is a different format this tool does not generate; the two are alternatives, not something you need both of.

    Is my data uploaded anywhere to generate the tags?

    No. Everything is assembled in your browser using JavaScript. Nothing you enter is transmitted, logged or stored.