hreflang Tags Generator

Pick a language and (optionally) a country for each URL. We output lowercase tags like en-gb, de-ch to match widely used examples in Search Central.

Permalink

Tip: Put the same hreflang block on every localized version. Each version should also canonicalize to itself.

Hreflang annotations

HTML <head> block
<link rel="alternate" hreflang="en" href="https://example.com/">
<link rel="alternate" hreflang="es-es" href="https://example.com/es/">
<link rel="alternate" hreflang="ar" href="https://example.com/ar/">
Sitemap XML (with xhtml:link)
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/"/>
    <xhtml:link rel="alternate" hreflang="es-es" href="https://example.com/es/"/>
    <xhtml:link rel="alternate" hreflang="ar" href="https://example.com/ar/"/>
  </url>
  <url>
    <loc>https://example.com/es/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/"/>
    <xhtml:link rel="alternate" hreflang="es-es" href="https://example.com/es/"/>
    <xhtml:link rel="alternate" hreflang="ar" href="https://example.com/ar/"/>
  </url>
  <url>
    <loc>https://example.com/ar/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/"/>
    <xhtml:link rel="alternate" hreflang="es-es" href="https://example.com/es/"/>
    <xhtml:link rel="alternate" hreflang="ar" href="https://example.com/ar/"/>
  </url>
</urlset>
Why hreflang matters for international SEO:
  • Helps search engines serve the correct language/region version to users, improving relevance and CTR.
  • Reduces duplicate-content confusion between similar localized pages (e.g., en-us vs en-gb).
  • Clarifies relationships across locales, supporting stable rankings during expansions and migrations.

How to use this tool effectively

  1. Add every locale URL for the same content. Use language-only when content is identical across regions (e.g., en), and language+country when there are regional differences (e.g., en-gb pricing).
  2. Keep tags reciprocal: each version must list itself and all others. If A links to B, B must link back to A.
  3. Use lowercase codes like en-gb, de-ch for consistency with common examples. Codes are case-insensitive, but consistency helps audits.
  4. Add x-default for a global fallback (language/region selector or generic page).
  5. Prefer a single method: HTML or Sitemap XML. (HTTP Link headers are an alternative but less commonly used.)
  6. Use valid ISO codes: language in ISO-639-1 and region in ISO-3166-1 alpha-2 (for example, use gb, not uk).
  7. Self-canonicalize every localized page; don’t canonicalize across locales.

See the official references above for full details and examples.

FAQ: hreflang & international SEO

1) What is hreflang and when do I need it?
Use hreflang when you have pages that are the same or very similar but targeted to different languages and/or regions. It signals to search engines which version to show to which users.

2) Language-only vs language+country: which should I use?
If the content is identical for all regions of a language, use language-only (e.g., en). If you localize by market (currency, shipping, legal copy), use language+country (e.g., en-gb, en-au).

3) Do I need x-default and what should it point to?
x-default is optional but recommended when you have a language/region selector or a global fallback page. Point it to a neutral, non-localized destination.

4) Where should I place hreflang annotations?
Use either the HTML <head> links on every localized page or a dedicated Sitemap XML with xhtml:link entries. Pick one method for simpler maintenance.

5) What are the most common hreflang mistakes?
Missing reciprocity, wrong country codes (e.g., using uk instead of gb), mixing http/https or trailing slashes inconsistently, pointing to non-canonical URLs, and forgetting self-references.

Usage note: This generator formats hreflang annotations from the rows you enter; it doesn’t fetch or store any pages. Ensure each URL returns a live 200 and is canonical to itself. To validate reciprocity and live pages, try our Hreflang Tags Validator.

Why this output matters

Correct hreflang annotations help search engines serve the appropriate language or regional URL to users. The generated output matters for international SEO because inconsistent locale codes, missing self-references or wrong URLs can weaken regional targeting.

Related tools

All tools