If your website targets visitors in different countries or languages, you need to help search engines understand which version of a page to show. That’s where hreflang tags come in. They tell Google which version of your page belongs to which audience. Done right, they improve rankings, reduce duplicate content issues, and give users the right page for their location or language.
Let’s break this down step by step in plain language.
What Is Hreflang?
Hreflang is an HTML attribute that tells search engines the language and country version of a webpage. Think of it as a signpost. It says:
- “This page is for English speakers in the US.”
- “This one is for French speakers in Canada.”
Without hreflang, Google may not know which page to show. Users in France might see your US page instead of your French page.
How Hreflang Works
Hreflang uses a language code and sometimes a country code.
Examples:
- en = English
- fr = French
- es = Spanish
- en-us = English, United States
- en-gb = English, United Kingdom
- fr-ca = French, Canada
Each page on your site should have an hreflang tag pointing to its versions.
Ways to Add Hreflang
You can implement hreflang in three main ways:
1. In the Page Header
Add this code inside the <head> of your page:
<link rel=”alternate” hreflang=”en-us” href=”https://example.com/us/” />
<link rel=”alternate” hreflang=”en-gb” href=”https://example.com/uk/” />
<link rel=”alternate” hreflang=”x-default” href=”https://example.com/” />
- hreflang=”en-us” → English page for the US.
- hreflang=”en-gb” → English page for the UK.
- x-default → fallback page if no language matches.
2. In the Sitemap
You can also place hreflang attributes inside your XML sitemap. This is easier for large websites.
Example:
<url>
<loc>https://example.com/us/</loc>
<xhtml:link rel=”alternate” hreflang=”en-us” href=”https://example.com/us/” />
<xhtml:link rel=”alternate” hreflang=”en-gb” href=”https://example.com/uk/” />
</url>
3. In HTTP Headers
This method is used for non-HTML files like PDFs. You send hreflang in the response header.
Common Mistakes to Avoid
- Forgetting return links: If page A points to page B, then page B must point back to page A.
- Using wrong codes: en-uk is invalid. Use en-gb instead.
- Not setting x-default: Always set a fallback page.
- Skipping self-referencing: Each page must include its own hreflang too.
How to Check If It’s Working
You don’t need to guess. Use these tools:
- Google Search Console → “International Targeting” report
- Screaming Frog SEO Spider → Crawl and check hreflang tags
- Ahrefs or SEMrush Site Audit → Check hreflang issues
Hreflang Best Practices
- Use ISO language and country codes.
- Always point back (two-way linking).
- Add self-referencing hreflang.
- Use x-default for global or selector pages.
- Test your setup before going live.
- Keep hreflang updated when you add new pages.
FAQs
Q: Do I need hreflang if my site is only in one language?
No. Hreflang is only needed for multilingual or multi-country websites.
Q: Should I use hreflang or canonical tags?
Use both. Canonical tells search engines about duplicates. Hreflang tells them about language targeting.
Q: What happens if I don’t use hreflang?
Google may show the wrong page to users. That can hurt user experience and sales.
Q: Can plugins add hreflang in WordPress?
Yes. Plugins like Polylang, WPML, and Rank Math SEO can generate hreflang automatically.
Final Thoughts
Hreflang can look complex at first. But when broken down, it’s simple: it tells search engines which version of your content belongs to which audience.
If you run an international site, take the time to implement hreflang correctly. It improves user experience, boosts SEO, and helps your site reach the right people in the right place.
Start small: add hreflang to your main language versions, test in Google Search Console, and expand from there.