Hreflang Tag Generator — HTML, XML & HTTP Header Output
Add your locale–URL pairs and get valid hreflang tags in three formats simultaneously: HTML <link> tags for the <head>, XML sitemap syntax, and HTTP Link header format. Built-in validation catches missing self-references, non-bidirectional links, and invalid ISO codes. Supports x-default, base URL auto-fill, and 60+ locale codes.
Add locale–URL pairs — get HTML, XML sitemap, and HTTP header hreflang tags instantly
Add locale-URL pairs on the left to generate hreflang tags.
Rate this tool
How to generate hreflang tags
The most complete free hreflang tag generator
LazyTools vs other hreflang generators
| Feature | LazyTools | Aleyda Solis | SISTRIX | GeoTargetly |
|---|---|---|---|---|
| Output formats | ✅ HTML + XML + HTTP | ⚠ HTML only | ⚠ HTML only | ⚠ HTML only |
| Live validation | ✅ Real-time | ❌ No | ❌ No | ❌ No |
| Auto x-default toggle | ✅ Yes | ⚠ Manual | ⚠ Manual | ⚠ Manual |
| Base URL auto-fill | ✅ Yes | ❌ No | ❌ No | ❌ No |
| Download output | ✅ .txt download | ❌ No | ❌ No | ❌ No |
| Account required | ✅ None | ✅ None | ⚠ Login | ❌ Account |
| Locale limit | ✅ Unlimited | ⚠ 50 URLs | ✅ Unlimited | ❌ Paid tiers |
Hreflang Tags — Complete Guide to International SEO Implementation
Hreflang tags are HTML attributes that tell search engines which language and regional version of a page to show users based on their preferences. Without them, a search engine may show your US English page to a UK user, your English homepage to a French speaker, or treat regional variants as duplicate content. Correct hreflang implementation is foundational for any website serving multiple countries or languages.
What is hreflang?
Hreflang (formally rel="alternate" hreflang) is an HTML link attribute introduced by Google in 2011. It signals three pieces of information to search engines: (1) that a page has alternate versions, (2) which language and/or region each version targets, and (3) the URL of each alternate. Google, Yandex, and Bing all support hreflang. Other search engines typically ignore it but are not harmed by it.
The basic syntax is:
<link rel="alternate" hreflang="en-US" href="https://example.com/us/" /> <link rel="alternate" hreflang="en-GB" href="https://example.com/uk/" /> <link rel="alternate" hreflang="fr-FR" href="https://example.com/fr/" /> <link rel="alternate" hreflang="x-default" href="https://example.com/" />
Hreflang language and country codes
| Hreflang value | Code | Meaning |
|---|---|---|
| English (any) | en | English language, any country |
| English (US) | en-US | English, United States |
| English (UK) | en-GB | English, United Kingdom |
| English (Australia) | en-AU | English, Australia |
| French | fr | French, any country |
| French (France) | fr-FR | French, France |
| German | de | German, any country |
| Spanish | es | Spanish, any country |
| Spanish (Spain) | es-ES | Spanish, Spain |
| Spanish (Mexico) | es-MX | Spanish, Mexico |
| Chinese Simplified | zh-CN | Chinese, China (Simplified) |
| Chinese Traditional | zh-TW | Chinese, Taiwan (Traditional) |
| Japanese | ja | Japanese |
| Fallback | x-default | Shown when no locale matches |
Three ways to implement hreflang
1. HTML head section (most common) — Add link tags inside the <head> of every page in the hreflang group. Simple to implement, no server configuration needed. Must be added to every page variant.
2. XML Sitemap — Add <xhtml:link> elements within each <url> block in your sitemap.xml. Best for large sites where adding tags to every page is impractical. Submit via Google Search Console.
3. HTTP Link headers — Configure your web server to send Link response headers. Best for non-HTML resources (PDFs), or when you can’t modify page HTML. Requires server configuration (Apache, Nginx, CDN rules).
The bidirectionality requirement
The most common hreflang mistake is one-directional implementation. Every page in a hreflang group must reference every other page in the group — including itself. If your English page references your French page, the French page must also reference the English page AND reference itself. Google validates hreflang by checking that all referenced pages confirm the relationship. If any page is missing from the reciprocal references, Google may ignore the entire hreflang set for that page.
Example: you have three pages — English (en), French (fr), German (de). Each page must contain all three <link rel="alternate"> tags: one pointing to en, one to fr, one to de, plus x-default.
Hreflang and canonical tags
Hreflang and canonical tags serve different purposes and can coexist. The canonical tag (<link rel="canonical">) tells search engines which URL to index when there are duplicates. Hreflang tells search engines which language/region version to show to which users. Both should point to the correct self-referencing URL on each page. Do not use a single canonical tag pointing to only one language version across all variants — each page should canonical to itself.
Common hreflang implementation mistakes
| Mistake | Impact | Fix |
|---|---|---|
| Missing self-reference | Google ignores hreflang for that page | Every page must include its own hreflang tag |
| Non-bidirectional | Google may ignore the entire group | All pages in group must reference each other |
| Relative URLs | Tags are ignored | Always use absolute, fully-qualified URLs |
| Wrong ISO codes | Tags are invalid | Use ISO 639-1 for language (en, not english), ISO 3166-1 for country (US, not USA) |
| Missing x-default | No fallback for unmatched users | Add hreflang="x-default" pointing to default URL |
| zh-Hans / zh-Hant | Google doesn't recognise script codes | Use zh-CN (Simplified) or zh-TW (Traditional) |
When do you need hreflang?
You need hreflang if your website has: content in multiple languages, the same content in one language targeting multiple countries (e.g. en-US and en-GB), or a mix of both. You do NOT need hreflang if your site is in a single language targeting a single country, or if all regional differences are handled by a single URL with user-side localisation (e.g. currency shown by IP without different page URLs).
Hreflang tag generator FAQ
An hreflang tag tells search engines which language and regional version of a page to show specific users. Implemented as link rel="alternate" hreflang="en-US" in the HTML head, XML sitemap, or HTTP header. Essential for multilingual and multi-regional sites.
hreflang="x-default" specifies the fallback page shown when no other locale matches the user. Use it for your language selector page or default English version. Not required, but strongly recommended for international sites.
Yes. If page A references page B, page B must reference page A. Every page in the group must link to every other page AND to itself. Google validates this mutual confirmation. One-directional hreflang may be ignored entirely.
Format: link rel="alternate" hreflang="language-REGION" href="https://absolute-url". Language: ISO 639-1 (en, fr, de). Country: ISO 3166-1 Alpha 2 (US, GB, FR). Examples: en (any English), en-US (US English), zh-CN (Simplified Chinese), x-default (fallback).
Three options: (1) HTML head section of every page. (2) XML sitemap (xhtml:link elements). (3) HTTP Link response headers. HTML head is most common. XML sitemap is best for large sites. HTTP headers for non-HTML files or when you can't edit HTML.
Yes, if you have separate pages for en-US, en-GB, en-AU, en-CA. Without hreflang, Google may show the wrong regional version or treat them as duplicates. Use en-US, en-GB, en-AU plus x-default for the default version.
Missing self-reference (every page must include its own hreflang tag). Non-bidirectional. Relative URLs (must be absolute). Wrong ISO codes (en not english, US not USA). Missing x-default. Using zh-Hans/zh-Hant instead of zh-CN/zh-TW.
Canonical: which URL to index (deduplication). Hreflang: which language/region version to show specific users. They coexist. Each page should canonical to itself AND have hreflang tags. Do not canonical all language versions to one URL.
Use zh-CN for Simplified Chinese (mainland China) and zh-TW for Traditional Chinese (Taiwan). zh-HK for Traditional Chinese Hong Kong. Do NOT use zh-Hans or zh-Hant — Google does not support script subtags in hreflang.
Not directly, but it prevents ranking cannibalization, ensures the correct regional version appears in the right country's SERPs, and reduces bounce rates (users see their language). Correct hreflang makes your international SEO strategy work as intended.
Best options: Yoast SEO plugin (auto-generates for multilingual setups), WPML plugin (handles automatically), Rank Math (supports configuration). Or manually via functions.php wp_head() hook. For large sites, XML sitemap method is cleanest.
The LazyTools Hreflang Tag Generator is 100% free with no account required. Add unlimited locale-URL pairs, get HTML, XML, and HTTP header output, validate, and download. No limits, no premium tier.
No official Google limit. Most sites have 2-30 variants. For 50+ variants, use the XML sitemap method rather than HTML head tags — it's easier to maintain and keeps HTML pages lighter. This tool has no limit on locale rows.