How to Add hreflang Tags
Expanding your website’s reach to international audiences can improve your revenue, but only if search engines show the users the correct version of your site. That’s where hreflang tags come in.
These pieces of code act as a guide, telling Google and other search engines which language or regional version of a site to serve, improving user experience and boosting SEO.
Adding hreflang tags might seem complicated at first, but with the right approach, it’s straightforward.
Whether you’re optimising for a bilingual audience or targeting multiple countries, we’ll walk you through everything you need to know to get it right.
Reach out to our team to have a technical SEO agency help with your international SEO.
How to Create a hreflang Tag
Creating a hreflang tag might sound technical, but it’s really about telling search engines which version of your content belongs to which language or region.
These tags are snippets of HTML code or HTTP headers that help Google and other search engines deliver the right content to the appropriate audience.
Here’s a breakdown of how to create one:
- Identify Your Languages and Regions: First, decide which preferred language and country codes you’re targeting in GB and en-US. For example, if you’re optimising for both the UK and the US, you’ll need tags for en-gb and en-us.
- Use the Correct Syntax: A hreflang tag follows this basic format:
<link rel=”alternate” hreflang=”language-region code” href=”URL” />
For example, to target Spanish speakers in Spain, your tag might look like this:
<link rel=”alternate” hreflang=”es-es” href=”https://example.com/es/” /> - Include a Self-Referencing Hreflang Tag: Every hreflang set needs a tag for the page itself. This ensures Google recognises the page as part of the group.
- Add a Default Tag (x-default): If you have a fallback page for users outside your specified regions, include an x-default tag:
<link rel alternate href=”x-default” href=”https://example.com/” />
With this structure, you’re ensuring Google has all the information it needs to match your content with the right audience based on language and region codes.
How to Add hreflang Tags
Depending on how your website is built, there are a few ways to add them effectively:
- In the HTML Head Section: For smaller sites or manual setups, adding hreflang tags directly in the <head> section of your HTML is often the easiest approach. Just paste your tags there, ensuring they follow the correct syntax.
- In HTTP Headers: If you can’t modify your HTML directly (e.g., for non-HTML files like PDFs), you can use HTTP headers instead. Here’s an example header:
Link: <https://example.com/en/>; rel=”alternate”; hreflang=”en-us” - Via Your Sitemap: For larger sites, adding hreflang attributes to your XML sitemap can save time. Each URL entry should include the relevant hreflang information, like this:
<loc>https://example.com/en/</loc>
<xhtml:link rel=”alternate” hreflang=”en-us” href=”https://example.com/en/” /> - Using a CMS or Plugin: If you’re working with a CMS like WordPress, plugins (like Yoast SEO or WPML) can handle hreflang for you, simplifying the process and lowering the risk of errors happening.
Whatever method you choose, double-check your implementation to make sure your tags are accurate, consistent, and error-free.
A small mistake can confuse search engines, negating all your hard work.
Do I Need hreflang?
Hreflang tags are essential if your website has an alternate version that targets audiences in different languages or regions.
They help Google understand the version of your content to show based on a user’s preferences or geographic location. If you’ve ever seen the wrong version of a site rank in search results—like a Spanish version showing up for English-speaking users—that’s what hreflang is designed to prevent.
You’ll need hreflang tags if:
- You Have Multilingual Content: If your site offers content in multiple languages, hreflang ensures users are directed to the correct language version. For example, Spanish speakers in Spain should land on your es-es page, not the general en-us version.
- You Target Different Regions with the Same Language: Even if your content is in the same language, hreflang helps target specific regions. For instance, British English (en-gb) differs from American English (en-us) in tone, spelling, and even pricing formats.
- You Want to Avoid Duplicate Content Issues: Search engines might view different versions of the same page as duplicate content. Hreflang tells Google that these pages are region-specific variations, not duplicates, preserving your SEO equity.
If your site serves a single language or region, you might not need hreflang, but implementing it can significantly improve user experience and rankings for businesses with an international audience.
How to Check hreflang
Once you’ve implemented hreflang tags, it’s crucial to verify that they’re working as intended. Here’s how you can check your hreflang setup:
- Use Google Search Console:
- Navigate to the “Coverage” or “International Targeting” report under “Legacy Tools and Reports.”
- Check for hreflang errors, such as missing tags, incorrect codes, or misaligned URLs.
- Browser Extensions and Tools:
- Use tools like the Hreflang Tag Checker Chrome extension to quickly identify hreflang tags on a specific page.
- These tools provide a straightforward view of your hreflang attributes, helping you spot inconsistencies.
- Screaming Frog:
- Do a crawl of your site using Screaming Frog SEO Spider.
- Switch to the “Hreflang” tab to review all hreflang annotations and verify their accuracy.
- Inspect HTTP Headers:
- If you’ve implemented hreflang via HTTP headers, use browser developer tools or cURL commands to inspect the headers and confirm the correct implementation.
- XML Sitemap Validation:
- If your hreflang tags are in your XML sitemap, open the sitemap in a browser or XML viewer and ensure that each <loc> entry has accurate hreflang annotations.
Double-checking hreflang implementation helps avoid common issues such as incorrect language codes, broken links, or missing self-referencing tags.
A clean and accurate hreflang setup ensures that your international audience always sees the most relevant version of your site.
Where to Put hreflang Tags
Hreflang tags can be implemented in three main spots, depending on your website’s setup and needs.
Here’s a breakdown of each option:
- In the HTML <head> Section:
This is the most common way of adding hreflang tags. Just place them in the <head> section of your HTML for each page. This method works well for smaller sites and is straightforward to manage. - In HTTP Headers:
For non-HTML files, like PDFs or other downloadable resources, hreflang tags can be added to HTTP headers. This ensures search engines still get hreflang information even if it’s not in the HTML. - In the XML Sitemap:
For large sites with numerous language or regional variations, adding hreflang attributes to your XML sitemap can be the most efficient option. This centralises the hreflang data, making it easier to manage and update.
No matter where you place your hreflang tags, ensure consistency and accuracy across all pages and versions. Misplaced or incorrectly formatted tags can confuse search engines and negate the benefits of hreflang implementation.
What Are the Benefits of Adding hreflang?
Adding hreflang tags to your website can improve its performance and user experience, especially if you’re targeting a global audience.
Here’s why they’re worth implementing:
- Improved User Experience: Hreflang ensures users are directed to the site version matching their language or region, helping to reduce frustration and bounce rates.
- Better SEO Performance: By signalling to Google which pages are for specific languages or regions, hreflang helps prevent issues with duplicate content and makes sure the right pages rank for the right audiences.
- Higher Conversion Rates: Users who land on the correct version of your site are more likely to engage with its content, trust your brand, and convert into customers.
- Enhanced Brand Reputation: Offering localised content demonstrates that you understand and respect the needs of your diverse audience, strengthening your brand’s reputation globally.
- Reduced Cannibalization: Without hreflang, multiple versions of the same page might compete with each other in search results. Hreflang resolves this by telling Google which version to prioritise.
In short, hreflang tags optimise your site for search engines and create a smoother, more personalised user experience.
Want to Work With a Technical SEO Team?
Implementing hreflang tags and managing a global SEO strategy can be complex—but you don’t have to do it alone.
At Prosperity Media, our technical SEO experts specialise in solving challenges like these, ensuring your website and all the pages it contains are perfectly optimised for international audiences.
Contact Prosperity Media today to have a technical SEO team with industry-proven results.
Matthew Barby, Senior Director of Acquisition at HubSpot
"Whenever I have companies ask me if there are any great agencies in Australia, I always point them to Prosperity Media. James and team are always pushing out incredibly impactful work, and their depth of knowledge around SEO and content marketing is up there with the best in the world."







