Hreflang Generator
Generate accurate hreflang tags for multi-language websites. Create HTML link tags and XML sitemap entries for international SEO.
No language versions added yet.
Add at least 2 versions to generate hreflang tags.
<link rel="alternate" hreflang="en" href="https://example.com/en/page" />
<link rel="alternate" hreflang="es" href="https://example.com/es/page" />
<link rel="alternate" hreflang="x-default" href="https://example.com/page" />
<url>
<loc>https://example.com/en/page</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/page"/>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/page"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/page"/>
</url>
- No validation issues found
- All URLs use absolute paths
- Self-referential tags included
- Add at least 2 language versions
What Are Hreflang Tags and Why Are They Important?
Hreflang tags (also called hreflang annotations) are HTML or HTTP headers that tell search engines about the relationship between web pages in different languages and regions. They help Google serve the correct language or regional URL in search results based on a user's language preference and location.
Without hreflang tags, you risk:
- Duplicate content issues - Search engines might see your different language versions as duplicate content
- Poor user experience - Users might see the wrong language version in search results
- Lower rankings - Without proper language targeting, your pages may not rank well in local search results
Hreflang Attribute Format Explained
The hreflang attribute follows ISO 639-1 for language codes and ISO 3166-1 Alpha 2 for country codes. Here are the valid formats:
hreflang="language-code-country" ← Language and country (e.g., "en-US" for US English)
hreflang="x-default" ← Default for all other languages
Common Examples:
hreflang="en"- Targets English speakers worldwidehreflang="en-US"- Targets English speakers in the United Stateshreflang="en-GB"- Targets English speakers in the United Kingdomhreflang="es"- Targets Spanish speakers worldwidehreflang="es-ES"- Targets Spanish speakers in Spainhreflang="es-MX"- Targets Spanish speakers in Mexico
Implementation Methods
1. HTML Link Tags (in <head> section)
Add link tags to the <head> section of each page. Each page must include references to all language versions including itself.
<link rel="alternate" hreflang="es" href="https://example.com/es/page" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/page" />
2. XML Sitemap Implementation
Add hreflang annotations directly in your XML sitemap. This is recommended for large websites as it's easier to manage.
<loc>https://example.com/en/page</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/page"/>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/page"/>
<xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/page"/>
</url>
3. HTTP Headers (for non-HTML files)
For PDFs or other non-HTML files, you can send hreflang information in the HTTP header:
<https://example.com/es/document.pdf>; rel="alternate"; hreflang="es"
Best Practices for Hreflang Implementation
- Use absolute URLs - Always use full URLs including https://
- Include self-referential tags - Each page should reference itself
- Bidirectional links - If page A links to page B, page B must link back to page A
- Validate your implementation - Use Google Search Console's International Targeting report
- Keep language and region codes lowercase - Use "en-us" not "EN-US" or "en-US"
- Specify x-default - This tells Google which version to show users whose language doesn't match any of your other versions
Common Hreflang Mistakes to Avoid
- Incorrect language/region codes - Using non-standard codes like "uk" instead of "en-GB"
- Missing return links - Forgetting to add reciprocal hreflang annotations
- Using relative URLs - Always use absolute URLs
- Conflicting canonical tags - Canonical URLs should point to the same language version
- Not including x-default - Especially important for global websites
- Mixing implementation methods - Choose one method (HTML or XML) and stick to it
Frequently Asked Questions (FAQ)
Do I need hreflang if I use separate country code TLDs (.de, .fr, .co.uk)?
Yes, you still need hreflang tags. While ccTLDs (.de, .fr) provide strong geo-signals, hreflang helps when:
- Users search from different countries
- Your content is in multiple languages on the same domain
- You have users with different browser language settings
What is the difference between hreflang and canonical tags?
Canonical tags tell search engines which version of similar pages is the "master" version to avoid duplicate content issues. Hreflang tags tell search engines about language/regional alternatives. They serve different purposes and can be used together. Each language version should have a self-referential canonical tag.
How many hreflang tags can I have per page?
There's no official limit, but Google recommends keeping it under 100 tags per page for performance reasons. Most websites need far fewer. Each page should have one hreflang tag for each language version including itself, plus optionally an x-default tag.
Should I use language-only or language-region codes?
Use language-region codes (e.g., "en-US") when:
- You have content variations for specific regions
- You have different prices/currencies by country
- Legal requirements differ by country
Use language-only codes (e.g., "en") when your content is the same for all regions speaking that language.