Master Hreflang Tags for International SEO
Complete technical guide for implementing hreflang tags correctly on multilingual websites. Learn best practices, avoid common mistakes, and boost your international SEO.
Meirra
SEO & Web Development Expert, Meirra

The Complete Hreflang Guide
Master multilingual SEO with confidence
Understanding Hreflang
The hreflang attribute tells search engines which language you're using on a specific page, so they can show the right version to users searching in that language.
Introduced by Google in 2011, hreflang is now a critical component of international SEO, helping avoid duplicate content issues and ensuring users see content in their preferred language.
The attribute uses ISO language codes (like 'en' for English or 'es' for Spanish) and optional regional subtags (like 'es-ES' for Spanish in Spain or 'es-MX' for Spanish in Mexico).
This comprehensive guide covers everything you need to properly implement hreflang tags for international websites. Hreflang implementation is one of the most technically challenging aspects of multilingual SEO, but when done correctly, it ensures search engines serve the right language version to the right users. Our platform tracks hreflang performance in real-time.
We'll walk through multiple implementation methods, provide tested code examples, offer specific guidance for international expansion, and help you troubleshoot common errors. All with live dashboard monitoring.
Basic Example
Basic Hreflang Implementation
HTML link elements in the head section
<head>
<!-- Other meta tags, title, etc. -->
<!-- English page (example.com/page) would have these tags: -->
<link rel="alternate" hreflang="en" href="https://example.com/page/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/page/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/page/" />
<!-- Spanish page (example.com/es/page) would have these same tags: -->
<link rel="alternate" hreflang="en" href="https://example.com/page/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/page/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/page/" />
</head>Why It Matters
- Prevents duplicate content issues across language versions
- Ensures search engines serve the correct language to users
- Helps maintain separate index rankings for each language version
- Improves user experience by showing content in users' preferred language
- Critical for businesses expanding into international markets
Common Mistakes
- ✕Missing return links (not creating bidirectional references)
- ✕Incorrect language or country codes
- ✕Mixing relative and absolute URLs
- ✕Conflicting canonical and hreflang signals
- ✕Improper nesting in XML sitemaps
- ✕Self-reference tags missing
Hreflang Language Codes
Explore valid language codes to use in your hreflang tags.
enEnglish
en-USEnglish (United States)
en-GBEnglish (United Kingdom)
en-CAEnglish (Canada)
en-AUEnglish (Australia)
esSpanish
es-ESSpanish (Spain)
es-MXSpanish (Mexico)
es-COSpanish (Colombia)
es-ARSpanish (Argentina)
frFrench
fr-FRFrench (France)
fr-CAFrench (Canada)
ptPortuguese
pt-BRPortuguese (Brazil)
pt-PTPortuguese (Portugal)
zhChinese
zh-CNChinese (China)
zh-TWChinese (Taiwan)
deGerman
de-DEGerman (Germany)
itItalian
it-ITItalian (Italy)
jaJapanese
ja-JPJapanese (Japan)
koKorean
ko-KRKorean (South Korea)
ruRussian
ru-RURussian (Russia)
arArabic
Code Format
Language codes follow ISO 639-1 standard. You can use language-only codes (e.g., 'en') or language-region combinations (e.g., 'en-US').
Hreflang Code Generator
Generate correct hreflang code for your multilingual website by entering your URLs below.
Instructions
- Enter your base domain (example.com)
- Add the pages you want to generate code for
- Specify which languages and regions each page is available in
- Choose your preferred implementation method (HTML, HTTP headers, or XML sitemap)
- Copy the generated code and implement it on your website
Hreflang Code Generator
Generate correct hreflang code for your multilingual website by entering your URLs below.
Domain Settings
Implementation Method
Pages
Available Languages
Code: 'en' for English, 'es' for general Spanish, 'es-ES' for Spain, 'x-default' for default
Generated Code
HTML Head Method
Implementation Tips
- Always include the x-default tag to handle users with language preferences that don't match any of your versions
- Make sure each language version includes links to all other language versions, including itself
- Use absolute URLs (starting with http:// or https://) in all hreflang tags
- Test your implementation with the tools mentioned in the testing section
- Remember that hreflang is a hint, not a directive - search engines may still show a different version if they think it's more relevant
- For consistency, use the same method (HTML head, HTTP headers, or XML sitemap) across your entire site
Additional Resources
Implementation Methods
Different ways to implement hreflang, each with its own advantages
Methods
Methods
HTML Head Tags
Add hreflang tags directly in the <head> section of each page
Direct control over tags on each page
Easy to implement for small sites
Works with all search engines
Code Examples
Basic HTML Implementation
<link rel="alternate" hreflang="en" href="https://example.com/page" />
<link rel="alternate" hreflang="es" href="https://example.com/es/page" />
<link rel="alternate" hreflang="x-default" href="https://example.com/page" />Real-world Example
Here's an example of what hreflang implementation looks like on a real website:
Booking.com (HTML Head Implementation)
Booking.com website uses hreflang tags in the head for each language/region
<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta charset="utf-8">
<title>Guía de Viajes España | Booking.com</title>
<!-- Self-reference (Spanish - Spain) -->
<link rel="alternate" hreflang="es-ES" href="https://www.booking.com/destinacione/pais/es.es.html" />
<!-- Other language versions -->
<link rel="alternate" hreflang="en-GB" href="https://www.booking.com/destinations/country/es.en-gb.html" />
<link rel="alternate" hreflang="en-US" href="https://www.booking.com/destinations/country/es.html" />
<link rel="alternate" hreflang="de" href="https://www.booking.com/destinations/country/es.de.html" />
<link rel="alternate" hreflang="fr" href="https://www.booking.com/destinations/country/es.fr.html" />
<link rel="alternate" hreflang="it" href="https://www.booking.com/destinations/country/es.it.html" />
<!-- Default version -->
<link rel="alternate" hreflang="x-default" href="https://www.booking.com/destinations/country/es.html" />
<link rel="canonical" href="https://www.booking.com/destinacione/pais/es.es.html" />
<!-- Other meta tags... -->
</head>
<body>
<!-- Page content -->
</body>
</html>Note: This is a simplified example based on real implementations. Actual implementations may vary.
Pro Tips
Include self-referencing tags
Use absolute URLs
Verify bidirectional links
HTTP Headers
Return hreflang information in HTTP response headers
Works for non-HTML files (PDFs)
Doesn't affect HTML page size
Can be managed server-side
Code Examples
HTTP Header Example
Link: <https://example.com/page>; rel="alternate"; hreflang="en",
<https://example.com/es/page>; rel="alternate"; hreflang="es"Real-world Example
Here's an example of what hreflang implementation looks like on a real website:
Adobe Documentation (HTTP Headers)
Adobe uses HTTP headers to indicate language versions of their PDF files
HTTP/1.1 200 OK
Date: Tue, 29 Apr 2025 10:15:30 GMT
Content-Type: application/pdf
Content-Length: 2864721
Link: <https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf>; rel="alternate"; hreflang="en",
<https://www.adobe.com/content/dam/acom/es/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf>; rel="alternate"; hreflang="es",
<https://www.adobe.com/content/dam/acom/de/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf>; rel="alternate"; hreflang="de",
<https://www.adobe.com/content/dam/acom/fr/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf>; rel="alternate"; hreflang="fr",
<https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf>; rel="alternate"; hreflang="x-default"
Cache-Control: max-age=86400
Server: AkamaiGHost
X-Content-Type-Options: nosniffNote: This is a simplified example based on real implementations. Actual implementations may vary.
Pro Tips
Test with curl or browser tools
Ensure proper header formatting
Check server configuration
XML Sitemap
Include hreflang information in your XML sitemap
Centralized management
Easier for large sites
Good for site-wide updates
Code Examples
XML Sitemap Implementation
<url>
<loc>https://example.com/page</loc>
<xhtml:link rel="alternate" hreflang="es" href="https://example.com/es/page" />
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/page" />
</url>Real-world Example
Here's an example of what hreflang implementation looks like on a real website:
IKEA (XML Sitemap Implementation)
IKEA uses an XML sitemap with hreflang annotations for their multiple regional versions
<?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://www.ikea.com/es/es/</loc>
<xhtml:link rel="alternate" hreflang="es-ES" href="https://www.ikea.com/es/es/" />
<xhtml:link rel="alternate" hreflang="en-GB" href="https://www.ikea.com/gb/en/" />
<xhtml:link rel="alternate" hreflang="de-DE" href="https://www.ikea.com/de/de/" />
<xhtml:link rel="alternate" hreflang="fr-FR" href="https://www.ikea.com/fr/fr/" />
<xhtml:link rel="alternate" hreflang="it-IT" href="https://www.ikea.com/it/it/" />
<xhtml:link rel="alternate" hreflang="pt-PT" href="https://www.ikea.com/pt/pt/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://www.ikea.com/" />
<lastmod>2025-04-20</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
<!-- Product page example -->
<url>
<loc>https://www.ikea.com/es/es/p/billy-libreria-blanco-00263850/</loc>
<xhtml:link rel="alternate" hreflang="es-ES" href="https://www.ikea.com/es/es/p/billy-libreria-blanco-00263850/" />
<xhtml:link rel="alternate" hreflang="en-GB" href="https://www.ikea.com/gb/en/p/billy-bookcase-white-00263850/" />
<xhtml:link rel="alternate" hreflang="de-DE" href="https://www.ikea.com/de/de/p/billy-buecherregal-weiss-00263850/" />
<xhtml:link rel="alternate" hreflang="fr-FR" href="https://www.ikea.com/fr/fr/p/billy-bibliotheque-blanc-00263850/" />
<xhtml:link rel="alternate" hreflang="x-default" href="https://www.ikea.com/p/billy-bookcase-white-00263850/" />
<lastmod>2025-04-18</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<!-- Additional URLs... -->
</urlset>Note: This is a simplified example based on real implementations. Actual implementations may vary.
Pro Tips
Include xhtml namespace
Submit to Search Console
Keep sitemap updated
Spanish Market Specifics
Important considerations when targeting Spanish-speaking markets
Regional Variations
Spanish varies significantly between Spain (es-ES) and Latin America. Consider using es-ES for Spain and es-MX or es-419 for Latin American markets.
Local Search Behavior
Spanish users often search differently than English users. Keywords may not be direct translations, and search intent can vary by region.
Domain Strategy
Consider using ccTLDs (.es for Spain) or subdirectories with proper geotargeting for better local visibility.
Content Localization
Beyond translation, adapt content for cultural relevance, local examples, currency, and measurement units.
CMS Implementation
How to implement hreflang in popular content management systems
WordPress
Popular CMS with strong multilingual support through plugins
Install and activate WPML
Configure languages and URL structure
WPML automatically adds hreflang tags
Recommended Plugin:
WPML (WordPress Multilingual Plugin)Shopify
E-commerce platform with built-in multilingual features
Enable multiple languages in Shopify admin
Configure language-specific URLs
Use apps for advanced hreflang control
Recommended Plugin:
Langify or WeglotDrupal
Powerful CMS with built-in multilingual capabilities
Enable Language and Content Translation modules
Configure language detection and selection
Use Metatag module for hreflang
Recommended Plugin:
Core Multilingual ModulesWooCommerce
E-commerce plugin for WordPress with multilingual capabilities
Install and activate WPML or Polylang with their respective WooCommerce add-ons
Configure languages and translation settings
Translate products, categories, and checkout pages
Verify hreflang tags are properly implemented on product pages
Set up currency and payment gateways for different regions if needed
Recommended Plugin:
WPML with WooCommerce MultilingualMagento
Enterprise e-commerce platform with built-in multilingual support
Set up store views for each language/locale combination in your Magento admin
Configure the locale and language for each store view
Translate your content, products, and store information
Enable and configure the built-in hreflang tag generator
Verify implementation through view-source or browser dev tools
Recommended Plugin:
Built-in Store ViewsWebflow
Visual web design platform with custom code capabilities
Create separate pages or folders for each language version
Add custom code snippet in the head section of each page
Ensure each language version has links to all other language versions
Use absolute URLs for all hreflang references
Test implementation using browser developer tools
Recommended Plugin:
Weglot or custom codeCustom Frameworks
Headless CMS or custom-built solutions
Identify your site's language and regional structure
Create language detection and URL routing logic
Implement language switchers and proper redirects
Add hreflang tags to all page templates using your preferred method
Create automated testing to ensure bidirectional links are maintained
Recommended Plugin:
Custom implementationTesting & Validation
Tools and techniques to validate your hreflang implementation
Google Search Console
Google's official tool for monitoring hreflang implementation and identifying issues.
International Targeting report shows hreflang errors
Language and country targeting verification
Crawl coverage for different language versions
Direct feedback from Google's crawler
Hreflang Tags Testing Tool
Dedicated tool for validating hreflang implementation across your entire website.
Validates bidirectional links
Checks for proper language codes
Identifies missing return tags
Tests from multiple locations
Screaming Frog SEO Spider
Comprehensive SEO crawler that includes hreflang validation features.
Crawls entire site for hreflang tags
Exports hreflang data for analysis
Identifies implementation errors
Validates against XML sitemaps
Sitebulb
Visual website auditing tool with powerful hreflang analysis capabilities.
Visual hreflang mapping
Identifies orphaned language versions
Detailed implementation reports
Integration with Google Analytics
ContentKing
Real-time SEO monitoring platform that tracks hreflang changes.
Real-time hreflang monitoring
Alerts for implementation issues
Historical tracking of changes
API access for automation
Chrome Developer Tools
Built-in browser tools for quick hreflang verification.
View page source for manual inspection
Network tab to check HTTP headers
Console for JavaScript debugging
Free and always available
What to Look for When Testing
Technical Checks
- All tags have complete absolute URLs
- Valid language codes (es-ES, en-US, etc.)
- All pages include self-reference tags
- XML sitemap uses correct xhtml:link syntax
Structural Checks
- Complete bidirectional links between all versions
- x-default tag properly configured
- Consistency between canonical and hreflang tags
- No redirects interfering with hreflang
