Hreflang is an HTML attribute that tells Google which language and regional version of a page to serve to users based on their language preference and location. It's the cornerstone of international SEO for multilingual websites.
Without hreflang, Google may show your French users the English version of your site, or show users in Canada the content intended for users in Australia — losing rankings and conversions in the process.
What Does Hreflang Look Like?
Hreflang tags are placed in the <head> section of every language version of a page:
<!-- On the English page (yourdomain.com/about/) -->
<link rel="alternate" hreflang="en" href="https://yourdomain.com/about/" />
<link rel="alternate" hreflang="fr" href="https://yourdomain.com/fr/about/" />
<link rel="alternate" hreflang="ro" href="https://yourdomain.com/ro/about/" />
<link rel="alternate" hreflang="x-default" href="https://yourdomain.com/about/" />
Important: every page in the set must link to all other pages in the set, including itself. The French page must also carry all three hreflang tags.
Hreflang Language Codes
Hreflang uses ISO 639-1 language codes (2 letters) optionally combined with ISO 3166-1 region codes:
| Code | Meaning | Example use |
|---|---|---|
en | English (any region) | Global English audience |
en-US | English — United States | US-specific content (prices in USD) |
en-GB | English — United Kingdom | UK content (prices in GBP) |
fr | French (any region) | Global French audience |
fr-FR | French — France | France-specific |
ro | Romanian | Romanian audience |
de | German | German-speaking audience |
x-default | Fallback (no match) | Homepage or language selector |
What is x-default?
x-default is shown to users whose language doesn't match any of your hreflang entries. It typically points to your homepage, a language selection page, or your default language version. Always include it.
Three Ways to Implement Hreflang
1. HTML head tags (most common)
Place <link rel="alternate" hreflang="..."> tags in the <head> of each page. Works for all website types.
2. XML Sitemap
Declare hreflang relationships in your sitemap.xml using the <xhtml:link> element. Useful for large sites where adding tags to every page template isn't practical.
<url>
<loc>https://yourdomain.com/about/</loc>
<xhtml:link rel="alternate" hreflang="en" href="https://yourdomain.com/about/"/>
<xhtml:link rel="alternate" hreflang="ro" href="https://yourdomain.com/ro/about/"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://yourdomain.com/about/"/>
</url>
3. HTTP Headers
For non-HTML files (PDFs, for example), you can declare hreflang in the HTTP response header. Less common but valid.
Most Common Hreflang Mistakes
1. Missing return tags
The most common error: if page A links to page B in hreflang, page B must also link back to page A. If any page in the set is missing its return tags, Google ignores the entire hreflang annotation for that set.
2. URLs not returning 200
Every URL in your hreflang must return a 200 HTTP status. If a URL is redirected or returns 404, the hreflang tag is invalid.
3. Using language names instead of codes
<!-- Wrong -->
<link rel="alternate" hreflang="english" href="..." />
<!-- Correct -->
<link rel="alternate" hreflang="en" href="..." />
4. Not using absolute URLs
All URLs in hreflang must be absolute (including https:// and domain), not relative paths.
5. Forgetting x-default
Always include hreflang="x-default" pointing to your fallback page or language selector.
How to Validate Hreflang Implementation
Use the Optyxo Hreflang Validator:
- Enter your page URL
- The tool fetches all pages in the hreflang set
- Checks for return tags, valid language codes, accessible URLs, and x-default
- Reports any errors with specific fix recommendations
The Optyxo full SEO audit also checks hreflang as part of Technical SEO and flags missing or misconfigured tags.
Frequently Asked Questions
Does hreflang affect Google rankings?
Hreflang doesn't directly improve rankings, but incorrect implementation can hurt rankings in international markets. It ensures Google shows the right language version to the right users — if it's misconfigured, you lose visibility in those markets. Correct hreflang also prevents duplicate content issues between language versions.
Does hreflang work for country targeting or just language?
Both. You can target by language alone (hreflang="en"), by language and country (hreflang="en-US"), or have multiple regional versions of the same language (en-US, en-GB, en-AU). Use country codes only when the content is genuinely different for that country (pricing, currency, availability).
Can I use hreflang on a site with only two languages?
Yes — even a simple two-language site (English + Romanian, for example) benefits from hreflang. Without it, Google may choose which version to show users based on its own signals, which may not align with your intentions.
How long does it take for hreflang to take effect?
Google processes hreflang tags the next time it crawls your pages — typically within a few days to a few weeks depending on your crawl frequency. Check Google Search Console's International Targeting report to verify Google is recognizing your hreflang implementation correctly.