Skip to main content

Hreflang Tag Generator

Generate hreflang annotations for international and multilingual SEO. Add language-region pairs with URLs, validate ISO 639-1 language codes and ISO 3166-1 country codes, and copy the output as HTML link tags, XML sitemap entries, or HTTP Link headers. x-default auto-generation included.

Paste one entry per line as lang-region, https://url/. Comma or whitespace works as separator.

/* Add language variants above to generate hreflang tags. */

How to Use This Tool

  1. Add a language variant for each translated or localized version of your page. Click Add Language Variant to spawn a new row; choose the ISO 639-1 language code from the dropdown (for example, en, es, fr) and optionally an ISO 3166-1 Alpha-2 region code.
  2. Paste the absolute URL for that variant. URLs must be absolute (start with http:// or https://) and should return a 200 OK at that exact address — no redirects.
  3. Enable x-default (recommended for sites with three or more variants). x-default tells Google which URL to serve when no other language matches the user. Leave the URL empty to auto-use your first row; or paste a dedicated language-selector page.
  4. Use Bulk Paste Mode for large catalogs. Each line should be en-US, https://example.com/en-us/. Click Parse and Add to insert every line as a row.
  5. Pick the output format that matches where you will place the tags: HTML link tags for the <head> of every variant page; XML sitemap xhtml:link entries for large sites; HTTP Link headers for non-HTML resources like PDFs.
  6. Copy the output and paste it into your page templates, sitemap, or server config. Remember the reciprocal rule — every page in the cluster (including the self-referencing one) must list the full set of alternate URLs for Google to accept the annotation.

About Hreflang & International SEO

Hreflang is Google's solution to one of international SEO's oldest headaches: how do you publish the same article, product page, or marketing landing page in a dozen languages without triggering duplicate-content demotion, and how do you make sure a French searcher lands on the French page rather than the English one? Introduced in 2011, the rel="alternate" hreflang="xx-YY" annotation gives webmasters a machine-readable way to declare every language and regional variant of a page, so Google (and Yandex) can serve the correct version based on the user's browser language and geographic IP.

The value of an hreflang tag has two parts: a required ISO 639-1 language code (two lowercase letters, for example en for English or zh for Chinese) and an optional ISO 3166-1 Alpha-2 region code (two uppercase letters, for example US for United States or DE for Germany), joined by a hyphen. Use en-US when content is specifically localized for American audiences (US dollar prices, imperial units, Amazon.com links), but use just en when the content is English-generic and serves speakers regardless of country. A common mistake is to use the wrong code in the wrong slot — UK is not a language, it is a country; en-GB is correct.

The reciprocal rule is the single most important hreflang concept, and the easiest to get wrong. Every page in a translation cluster must link to every other page in the cluster, including itself. If page A (English) points to page B (French) as an alternate, page B must also point back to page A, and both must include a self-referential hreflang="en-US" on the English page and hreflang="fr-FR" on the French page. If any reciprocal link is missing or broken, Google silently ignores the entire annotation, and you get the wrong-language-in-search-results problem all over again. This is why hreflang output is symmetric: the block of link tags is identical on every variant page. Many CMS platforms (WordPress Polylang, Shopify, Contentful) will render this block automatically once you have declared the translations.

Google supports three delivery methods, and they are ranked equal for the crawler but different in maintenance cost. HTML link tags in the <head> are the easiest to implement for small-to-medium sites with a handful of variants, and they are visible in view-source for debugging. XML sitemap annotations using the xhtml:link namespace centralize everything in one sitemap file — this is the best choice for large e-commerce catalogs where maintaining individual page tags is impractical. HTTP Link headers (Link: <url>; rel="alternate"; hreflang="...") are the only option for non-HTML resources like PDFs, and require server-side configuration in Apache, Nginx, or your CDN. Our tool generates all three formats so you can choose the one that fits your stack without switching tools.

The x-default value deserves special attention. Added by Google in 2013, hreflang="x-default" marks the URL to serve when no other variant matches the user's browser language or region. It is typically your global homepage, an English fallback, or a country-selector page. Without x-default, Google picks one of your variants arbitrarily, which may not match your business logic. For sites with three or more languages, always include x-default; our tool prompts you to enable it automatically. A neat pattern is to use your language-selector page (https://example.com/ that lists "English | Español | Français") as the x-default, so users who don't match any specific variant are asked to choose.

Common hreflang pitfalls we encounter on client audits: (1) underscores instead of hyphens — en_US is silently ignored by Google, must be en-US; (2) missing self-reference — each page must list itself; (3) linking to redirected URLs — the target should be a final 200 OK, not a 301 or 302; (4) mixing the three delivery methods on the same site — pick one and stick with it; (5) relative URLs — hreflang values must be absolute, full https:// URLs; (6) content that's not actually translated — using hreflang on near-duplicate English pages can backfire; (7) forgetting the x-default. Our tool's validation panel catches the code-level issues as you type. For a full audit of your existing hreflang implementation, combine this tool with our Sitemap Generator and our Redirect Chain Checker to verify every target URL returns 200 OK directly.

Frequently Asked Questions

What is hreflang?

Hreflang is an HTML attribute (rel="alternate" hreflang="xx-YY") that tells search engines which language and optional region a specific page is intended for. When you publish the same content in multiple languages or for different geographic markets, hreflang lets Google serve the correct localized version to each user and prevents the variants from competing with each other in search results. The value is a combination of an ISO 639-1 language code (required) and an optional ISO 3166-1 Alpha-2 region code, joined by a hyphen: en-US for American English, es-MX for Mexican Spanish, or simply fr for any French-speaking audience.

Why does hreflang matter for SEO?

Hreflang matters because without it, Google may show the wrong language version to your users (for example, serving the English page to a Spanish searcher), or worse, treat your localized variants as duplicate content and suppress all but one. Hreflang consolidates ranking signals across language variants while keeping each URL indexed separately for its target audience. For global businesses, missing or incorrect hreflang is one of the top causes of lost international traffic — users bounce when they land on the wrong language, and Google notices those signals.

How do I use x-default?

The special value hreflang="x-default" tells search engines which URL to show when no other language variant matches the user's browser or location. It is typically your global homepage or a language-selector page. If you do not specify x-default, Google will pick one of your variants as a fallback, which may not be the best experience. Best practice is to always include x-default when you have three or more language variants — our tool auto-suggests x-default and defaults to your first row's URL if you do not override it.

What is the reciprocal hreflang rule?

Hreflang must be reciprocal: if page A (en-US) links to page B (fr-FR) as an alternate, then page B must also list page A as an alternate. If the reciprocal link is missing or points to a different URL, Google ignores the annotation entirely. This means every page in a translation set must include the complete list of all language variants, including itself. Our tool output can be copy-pasted into every variant page because the link tags are the same across the cluster.

What is the difference between ISO 639-1 and ISO 3166-1?

ISO 639-1 is the standard for two-letter language codes: en for English, fr for French, zh for Chinese, ar for Arabic. ISO 3166-1 Alpha-2 is the standard for two-letter country/region codes: US, GB, FR, DE, JP. Hreflang combines a required language code with an optional region code, like en-US or fr-CA. Use language-only when the content is the same everywhere that language is spoken (for example, simply "fr" if your French page serves France, Belgium, Canada, and Switzerland equally). Use language-region when content is specifically localized for that market — pricing in local currency, regional product availability, local shipping information.

Hreflang in HTML, sitemap, or HTTP headers — which should I use?

Google supports three delivery methods and treats them equally. HTML link tags in the <head> are the easiest for small sites and give you per-page control; every page must list the full cluster. XML sitemap annotations (xhtml:link) centralize the mapping in one file and are ideal for large sites with many pages — no need to edit every HTML file. HTTP Link headers are the best choice for non-HTML resources like PDFs. Pick one method and stick with it across your entire site — mixing methods can cause ambiguity. Our tool outputs all three formats so you can pick the one that fits your stack.

What are common hreflang mistakes?

The most common hreflang mistakes are (1) using underscores instead of hyphens (en_US instead of en-US — Google treats the first as invalid), (2) using a country code in the language slot (like UK instead of en-GB — UK is not a language, it is a country), (3) pointing to URLs that return 404 or redirect, (4) missing reciprocal annotations, (5) omitting self-referential hreflang on each page, (6) using relative URLs (they must be absolute), and (7) forgetting x-default when you have many variants. Our tool's validation panel catches most of these errors automatically as you add rows.

Does hreflang directly affect rankings?

Hreflang is not a ranking signal in itself — Google does not boost or demote pages that have hreflang tags. What hreflang does is indirectly improve your results by (a) ensuring the correct language variant shows up in the correct market, (b) preventing duplicate-content confusion between near-identical translations, and (c) consolidating backlinks and user signals across the cluster so the right page benefits from them. The effect on traffic can be substantial for global brands — we regularly see 20-40% uplift in non-English organic traffic after proper hreflang implementation, simply because users are no longer bouncing from the wrong-language page.

Reach a Global Audience with Confidence

Our SEO team configures complete international SEO — hreflang tags, geo-targeting, country-specific content, and multi-region sitemaps — for global reach.

Let's Talk