Back to all insights
Developer Tips

Hreflang Tags Guide: How to Use Them on Multilingual Sites

DH

Dev Hackes Administrator

Administrator

Jul 10, 2026
8 min read
Hreflang Tags Guide: How to Use Them on Multilingual Sites

Hreflang Tags Guide: How to Use Them on Multilingual Sites

If your website has content in more than one language, or you target different countries with the same language, you have probably run into a frustrating problem. A user in France searches for your product, but Google shows them the English version of your page instead of the French one. Or worse, your Spanish and Mexican pages compete against each other in search results instead of showing up correctly for the right audience.

This is exactly what hreflang tags are built to fix.

In this guide, we will break down what hreflang tags are, why they matter for SEO, and how you can implement them correctly on your website without breaking anything.

What Is a Hreflang Tag?

A hreflang tag is a small piece of HTML code that tells search engines like Google which language and, optionally, which country a specific page is meant for. It works like a signpost. Instead of guessing which version of your page to show a visitor, search engines use the hreflang tag to serve the most relevant version based on the user's language and location.

A basic hreflang tag looks like this:

html
<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/" />
<link rel="alternate" hreflang="es" href="https://example.com/es/" />

Here, "en" stands for English, "fr" for French, and "es" for Spanish. You can also target specific regions by adding a country code, such as "en-us" for English speakers in the United States or "en-gb" for English speakers in the United Kingdom.

Why Hreflang Tags Matter for SEO

Many website owners assume that once they translate their content, search engines will automatically figure out which page to show to which audience. Unfortunately, that is not how it works. Without hreflang tags, search engines are left guessing, and this often leads to a few common problems.

Duplicate content confusion. If you have the same content in English for both the US and UK, search engines may treat these pages as duplicates instead of understanding they serve different regions.

Wrong page shown to users. Someone searching in German might land on your English homepage instead of the German version, even if both exist on your site. This hurts user experience and increases bounce rate.

Pages competing against each other. Instead of your French and English pages both ranking well for their respective audiences, they may end up competing for the same search results, weakening both.

Hreflang tags solve these issues by clearly telling search engines, "this page is for French speakers, this one is for English speakers in the US, and this one is for English speakers in Australia." The result is better rankings, better user experience, and more relevant traffic.

Where Should Hreflang Tags Be Placed?

There are three common ways to implement hreflang tags, depending on how your website is built.

1. In the HTML Head Section

This is the most common method for smaller websites. You add the hreflang links directly inside the <head> tag of each page, listing all the language and regional versions available.

2. In the XML Sitemap

For larger websites with hundreds or thousands of pages, adding hreflang tags directly in the sitemap is often more practical. This keeps your HTML clean and makes it easier to manage translations at scale.

3. In the HTTP Header

This method is mostly used for non-HTML files, such as PDFs, where you cannot add tags inside a <head> section. It is less common but useful in specific cases.

Whichever method you choose, consistency is key. Do not mix methods across your site, as this can confuse search engines rather than help them.

Common Mistakes to Avoid

Even experienced website owners make mistakes with hreflang implementation. Here are the ones you should watch out for.

Missing the return tag. Hreflang tags must be reciprocal. If your English page points to your French page, the French page must also point back to the English page. If this return link is missing, search engines may ignore the tag entirely.

Incorrect language or country codes. Using "eng" instead of "en" or "uk" instead of "gb" for the United Kingdom is a common error. Always use standard ISO 639-1 language codes and ISO 3166-1 Alpha 2 country codes.

Forgetting the x-default tag. The x-default tag tells search engines which page to show when no other language or region matches the user. This is especially important for your homepage or landing page.

Not including self-referencing tags. Every page should also include a hreflang tag pointing to itself. This might sound unnecessary, but Google's guidelines specifically recommend it for accuracy.

Broken or outdated links. If you update your URL structure but forget to update your hreflang tags, you end up pointing search engines to pages that no longer exist, which wastes crawl budget and confuses indexing.

How to Add Hreflang Tags the Easy Way

Manually writing hreflang tags for a site with many languages and regions can get messy fast, especially when you have to keep track of reciprocal links between every page. A small mistake in one tag can affect how your entire multilingual site is indexed.

This is where using a dedicated hreflang tag generator becomes useful. Instead of writing the code by hand and risking errors, you simply enter your URLs and target languages, and the tool generates clean, correctly formatted tags ready to paste into your site. This saves time and reduces the chance of the common mistakes mentioned above, especially for site owners managing multiple language versions without a dedicated development team.

Testing Your Hreflang Implementation

After adding hreflang tags, do not assume everything is working correctly. Always test your implementation using tools like Google Search Console's International Targeting report, which shows any errors Google has detected in your hreflang setup. You can also use third-party hreflang testing tools to check for missing return tags or incorrect codes before they cause ranking issues.

Final Thoughts

Hreflang tags might seem like a small technical detail, but they play a big role in how well your multilingual or multi-regional website performs in search results. Getting them right means your French visitors see French content, your US visitors see US-specific pricing and spelling, and your site avoids the duplicate content penalties that come from serving similar content across multiple regions without clear signals.

If you are managing a website with multiple language versions, take the time to review your hreflang setup today. It is one of the simplest technical SEO fixes that can lead to noticeably better international search performance.

Privacy First

Tired of uploading files to untrustworthy sites?

Dev Hackes operates 100% locally in your web browser. No databases store your assets. No server overhead.

Explore Local Tools →