How to Use the Hreflang Generator — International SEO Guide
If you have a multilingual website and your international pages aren't ranking in their target regions, the culprit is almost always incorrect or missing hreflang tags. This guide covers everything you need to know about hreflang implementation.
What Is the Hreflang Attribute?
The hreflang attribute is an HTML link element that tells Google which language and regional version of a page to serve to users in different locations. It was introduced by Google in 2011 specifically to solve the challenge of multilingual websites.
The basic syntax is:
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
Why Hreflang Matters
Without hreflang tags:
- Google may serve your English page to Spanish-speaking users
- Your different language versions may compete against each other for the same search
- The wrong regional version may rank in the wrong country
- Google may see your translated pages as duplicate content
With hreflang:
- Each language version gets served to its intended audience
- You capture search traffic in multiple languages and regions
- Translated pages don't compete with each other
- You build authority in multiple markets simultaneously
Hreflang Language and Region Codes
The hreflang value combines a language code (ISO 639-1) with an optional region code (ISO 3166-1 Alpha-2):
en— English (any region)en-US— English in the United Statesen-GB— English in the United Kingdomes— Spanish (any region)es-MX— Spanish in Mexicopt-BR— Portuguese in Brazilzh-Hans— Simplified Chinesex-default— Default fallback (no language/region match)
How to Use the Hreflang Generator
Step 1: Add Your Pages
For each language/region version of your content, add an entry with:
- The full URL of that language version
- The language code
- An optional region code
Step 2: Set the x-default
Mark one URL as the x-default — this is shown to users whose language/region isn't covered by your other variants. Usually this is your main English or global page.
Step 3: Generate
Click "Generate Hreflang Tags" and get the complete set of HTML link tags.
Step 4: Add to Every Page
The critical rule: every language version must include hreflang tags pointing to all other language versions, including itself. If you have 6 language versions, each page has 6 hreflang tags.
The Bidirectional Requirement
This is the most common hreflang mistake. Each page must point to all other versions AND include a self-referencing hreflang:
<!-- On the English page (en) -->
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
<!-- On the Spanish page (es) — MUST also have both tags -->
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
Hreflang in XML Sitemaps
As an alternative to placing hreflang in every page's HTML, you can specify hreflang relationships in your XML sitemap. This is often more manageable for large sites:
<url>
<loc>https://example.com/en/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/"/>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/"/>
</url>
Common Hreflang Mistakes
- Broken bidirectionality: Page A points to Page B, but Page B doesn't point back to Page A
- Incorrect language codes: Using
en-ukinstead ofen-gb - Missing x-default: Every site should have an x-default fallback
- Using relative URLs: Always use absolute URLs including the protocol
- Only adding to some pages: Hreflang must be consistent across all language versions
Conclusion
Hreflang tags are essential for any website targeting users in multiple languages or regions. They ensure the right content reaches the right audience and prevent duplicate content issues across translations. Use our free Hreflang Generator to create perfectly formatted hreflang tags for all your language variants.
Complete your international SEO setup with our Sitemap Generator and Canonical URL Generator.
Written by
SEO Utilities Team
The SEO Utilities team is made up of SEO specialists, web developers, and digital marketers passionate about making professional-grade SEO tools free and accessible to everyone. We build, test, and refine every tool based on real-world SEO workflows.