If you’re running a multilingual website and watching your international traffic stagnate, the problem might be simpler than you think. Most businesses ignore one critical technical element that tells Google which language version to show—and it’s costing them rankings.
That element is hreflang.
This guide breaks down everything you need to know about hreflang attributes, why they matter for your bottom line, and exactly how to implement them without breaking your site.
What Exactly Is Hreflang?
Hreflang is an HTML attribute that tells search engines the language and geographic targeting of your web pages. Think of it as a label that says “this page is in Spanish for Mexican audiences” or “this page is in English for British users.”
The syntax looks like this: hreflang=”en-us” (English for United States) or hreflang=”fr-ca” (French for Canada).
When you have the same content translated into multiple languages or adapted for different regions, hreflang prevents Google from treating these as duplicate content. Instead, it signals that each version serves a specific audience with their preferred language and regional preferences.
Why Hreflang Matters for Your Search Rankings
Here’s what happens without proper hreflang implementation: Google shows your Spanish content to English-speaking users, or your UK-targeted page appears in Australian search results. Users bounce immediately because the content doesn’t match their expectations.
This creates three major problems:
Poor user experience. Someone searching in German who lands on your English page won’t stick around. High bounce rates signal to Google that your content isn’t relevant, which tanks your rankings.
Duplicate content penalties. When you have similar pages targeting different regions without hreflang tags, Google struggles to understand the relationship between them. The algorithm might pick the wrong version to index or split your ranking power across multiple URLs.
Lost international traffic. You’ve invested in translations and localized content, but without hreflang, you’re essentially hiding these versions from your target audiences. The ROI on that localization effort drops to zero.
Properly implemented hreflang ensures that German users searching on Google.de see your German pages, Mexican users find your Spanish (Mexico) content, and everyone gets the experience you designed for them.
The Three Ways to Implement Hreflang Tags
You have three options for adding hreflang to your site. Choose based on your technical setup and how many pages need tags.
HTML Header Implementation
The most common method involves adding link elements directly to your page’s <head> section. This works well for sites with a manageable number of localized pages.
Each page needs to reference itself and all its language variants. Here’s what the code structure looks like:
<link rel="alternate" href="https://example.com/" hreflang="en" /> <link rel="alternate" href="https://example.com/es/" hreflang="es" /> <link rel="alternate" href="https://example.com/fr/" hreflang="fr" />
The key rule: every page must include hreflang tags for itself and all alternate versions. Your English page needs tags pointing to the Spanish and French versions. Your Spanish page needs tags pointing to English and French. All variants must be cross-referenced.
XML Sitemap Method
For larger websites with hundreds of localized pages, managing hreflang in HTML headers becomes impractical. The XML sitemap method centralizes everything in one file.
In your sitemap XML file, add xhtml:link elements within each URL entry:
<url>
<loc>https://example.com/</loc>
<xhtml:link rel="alternate" href="https://example.com/" hreflang="en" />
<xhtml:link rel="alternate" href="https://example.com/es/" hreflang="es" />
</url>
This approach keeps your HTML clean while giving search engines the information they need. It’s particularly useful when your CMS doesn’t easily allow header modifications.
HTTP Header Implementation
If you’re serving non-HTML files like PDFs or other downloadable content in multiple languages, you can’t add hreflang tags to the document itself. Instead, implement it through HTTP headers.
The header format looks like this:
Link: <https://example.com/>; rel="alternate"; hreflang="en", <https://example.com/es/>; rel="alternate"; hreflang="es"
This method tells search engines about language variants before the content even loads.
Understanding Hreflang Language and Region Codes
Getting your codes right is non-negotiable. Use the wrong format and search engines will ignore your tags completely.
Language-Only Codes
When your content serves all speakers of a language regardless of location, use just the two-letter ISO 639-1 language code:
- hreflang=”en” — English (generic)
- hreflang=”es” — Spanish (generic)
- hreflang=”de” — German (generic)
Language and Region Codes
When you’ve localized content for specific countries, combine the language code with a two-letter ISO 3166-1 Alpha-2 country code, separated by a hyphen:
- hreflang=”en-us” — English for United States
- hreflang=”en-gb” — English for United Kingdom
- hreflang=”es-mx” — Spanish for Mexico
- hreflang=”fr-ca” — French for Canada
The X-Default Tag
The hreflang=”x-default” value designates your default page—the version shown when no other variant matches a user’s language or location. This catches everyone who falls outside your specified regions.
For a global business, your x-default might point to an English version or a language selector page.
Critical Best Practices That Prevent Ranking Issues
Only Use Canonical URLs
Your hreflang tags must reference canonical URLs—the primary version of each page that you want indexed. Never point hreflang to:
- Redirected URLs
- URLs with canonical tags pointing elsewhere
- Broken pages returning 404 errors
If you do, search engines will ignore your hreflang implementation entirely. Always verify that the URLs in your tags are the actual URLs you want ranking.
Keep Everything Synchronized
When you add a new language version, update the hreflang tags on every related page. If you remove a language, strip out those references everywhere. Outdated hreflang creates confusion and wastes your crawl budget.
Set up a process: whenever your content team publishes a localized page, your technical team updates the hreflang across all variants. This should be part of your standard workflow, not an afterthought.
Self-Reference Is Required
Every page must include an hreflang tag pointing to itself. Google uses this for validation. A Spanish page needs hreflang=”es” pointing to its own URL, plus tags for all other language versions.
Without self-referencing tags, Google may ignore the entire hreflang setup for that page.
Common Hreflang Mistakes That Kill Your International SEO
Most hreflang errors fall into a few predictable categories. Catch these early and you’ll avoid major ranking problems.
Invalid language or country codes. Typos happen, but hreflang=”eng” instead of hreflang=”en” breaks everything. Double-check against official ISO code lists.
Missing reciprocal links. If your English page references Spanish and French variants, those variants must reference the English version back. One-way references don’t work.
Using non-canonical URLs. Pointing hreflang at redirected or duplicate URLs confuses search engines about which page to index.
Forgetting the x-default. Without a fallback option, users outside your targeted regions might land on the wrong language version or get no results at all.
How to Audit Your Hreflang Implementation
Even perfect initial implementation can break over time as your site evolves. Regular audits catch problems before they impact rankings.
Tools like Semrush’s Site Audit automatically scan for common hreflang issues:
- Invalid or malformed codes
- Missing self-references
- Broken URL references
- Language code mismatches with actual page content
- Incomplete cross-referencing between variants
Run these audits quarterly, or immediately after launching new language versions. The free version crawls up to 100 pages monthly, which covers most small to medium-sized multilingual sites.
For manual verification, check your server logs. Are you seeing international traffic landing on the correct language versions? If German users keep hitting your English pages, something’s misconfigured.
When Hreflang Isn’t the Right Solution
Not every multilingual site needs hreflang. If you’re only targeting one country with one language, skip it. The attribute solves a specific problem: helping search engines differentiate between similar content for different audiences.
You also don’t need hreflang if you’re using completely different domains for different countries (example.com vs example.de vs example.fr). The distinct domains already signal geographic and language targeting to search engines.
Consider hreflang essential when:
- You have subdirectories for languages (example.com/en/ and example.com/es/)
- You use subdomains for regions (en.example.com and es.example.com)
- You have region-specific content using the same domain structure
Technical Considerations and Platform-Specific Solutions
Most modern content management systems offer plugins or built-in features for hreflang management. WordPress users can leverage plugins like WPML or Polylang, which automatically generate proper tags. Shopify handles this through its multi-language features once you’ve set up your market configurations.
If you’re coding custom solutions, remember that hreflang tags increase page weight slightly. For sites with dozens of language variants, XML sitemap implementation keeps your HTML lean while maintaining functionality.
Whatever your platform, avoid mixing implementation methods. Pick one approach—HTML headers, XML sitemap, or HTTP headers—and stick with it across your entire site. Mixing methods creates conflicts and unpredictable behavior.
The Bottom Line
Hreflang isn’t optional for international websites. It’s the technical bridge between your localization efforts and actual ranking improvements in target markets.
The implementation requires precision, but the payoff is substantial: better user experience, higher engagement from international audiences, and clear signals to search engines about your site structure. Get it right once, maintain it properly, and you’ll see your international organic traffic climb steadily.
Start with an audit of your current setup using site audit tools, fix any existing errors, and establish a maintenance process for new content. Your international SEO strategy depends on these technical foundations working correctly—make sure they do.














