✨ Get 25% OFFon any plan. Use the coupon:

What hreflang is and how to use it in international SEO

By Tiago CostaUpdated on July 2, 2026

Illustration of a globe connected to three versions of a page marked with the language codes PT, EN and ES, representing hreflang in international SEO.
Definition

Hreflang is an attribute that tells Google the language and region of a page, to serve the right version to each user. It is used to:

  • connect the versions of the same page in different languages;
  • show the correct version by country or language in search;
  • prevent similar pages from competing with each other;
  • improve the experience of the international audience.

What hreflang is

Hreflang is an HTML attribute (from href lang, that is, the language of the link) that signals to search engines in which language and, optionally, for which region a page was made. With it, Google knows that the Brazilian Portuguese version, the Spanish one and the English one of the same article are equivalent, and shows the right one to each person.

Without that signal, an international site runs two risks: showing the wrong version (a Brazilian landing on the English page) and seeing the similar versions competing with each other in search, a problem close to that of the canonical URL and duplicate content. Hreflang solves that by connecting the versions and making clear who each one serves.

Because it deals with the structure and the signals the search engine reads, not with the visible text, hreflang is a classic technical SEO topic.

How the hreflang tag works

Each hreflang tag points to a version of the page and states its language using the ISO 639-1 code (like pt, es, en). When the page is specific to a country, you also add the region code in the ISO 3166-1 alpha-2 format (like pt-BR, es-MX, en-US).

The logic has two golden rules:

  • Bidirectionality: if page A points to B, B needs to point back to A. Without that return, the search engine ignores the set.
  • Self-reference: each page must include a hreflang tag pointing to itself, besides the ones pointing to the other versions.

A simple example of a set for three languages would be one tag for pt-BR, one for es and one for en, all present on each of the three pages. That way Google assembles the complete cluster of versions and understands that they are the same page in different languages.

Infographic of the anatomy of a hreflang tag, showing the language code and the region code and the return arrows between the PT-BR, EN-US and ES-MX versions.
Anatomy of a hreflang tag: the language code and the region code that tell Google who sees each version.

Where to implement hreflang: HTML, sitemap or HTTP header

There are three ways to declare hreflang, and you choose one according to the type of content:

  • Tags in the HTML: link tags in the head of each page, with the rel="alternate" attribute and the hreflang. It is the most common method for traditional HTML pages.
  • XML sitemap: declaring the versions inside the XML sitemap keeps hreflang out of the page code, which helps on large sites and reduces the weight of the HTML.
  • HTTP header: suited for files that are not HTML, like PDFs, since they have no head to receive the link tags.

Whatever the method, the result needs to reach the search engine during indexing, so it is worth confirming that the tags appear in the rendered version of the page, not only in the code sent to the browser.

Hreflang and the canonical URL: how they work together

A common confusion is mixing hreflang with the canonical tag. They solve different problems and need to be consistent with each other:

  • The canonical URL points to the preferred version of a page when there are duplicates in the same language.
  • Hreflang connects versions in different languages or regions, which are not duplicates but translations.

The rule that avoids most problems: each page must have a canonical tag pointing to itself (self-canonical), never to the version in another language. If the Spanish page declares the English version as canonical, hreflang conflicts and Google may simply ignore both. The canonical handles duplicates; hreflang handles language.

Illustration comparing canonical, which chooses the preferred version in the same language, and hreflang, which connects pages in different languages.

Common hreflang mistakes

Implementing hreflang is conceptually simple, but people get it wrong a lot in practice, and a single slip can bring down the entire set. The most frequent problems are:

  • Missing self-reference: forgetting the tag in which the page points to itself.
  • Missing return: page A points to B, but B does not point back.
  • Wrong codes: using UK instead of GB, or swapping language and region.
  • Broken or noindex URLs: pointing to pages that redirect, throw an error or are out of the index.

The scale of the problem shows up in the data. A Semrush study of 20,000 multilingual sites found hreflang conflicts in the source code on 58% of them and errors in the tag value on 15%. In other words, more than half of the analyzed sites had some hreflang problem, which reinforces the importance of validating the implementation.

How to validate hreflang and best practices

After implementing, test before you trust. A few practices keep hreflang healthy:

  • Use a validator: SEO audit tools flag missing returns, invalid codes and broken URLs automatically.
  • Check the codes: review each language and region in the correct ISO standard before publishing.
  • Ensure self-reference and return: the two rules that cause the most errors.
  • Point only to indexable pages: no URLs with noindex, redirect or error.
  • Add the x-default: a value that indicates the default page for languages or regions with no specific version.

With the set validated and consistent, hreflang does the invisible work of delivering to each visitor the version of your content in the right language, which improves the experience and protects the site's performance in every market.

FAQ

Frequently asked questions

What are hreflang tags?

Hreflang tags are markups that tell the search engine the language and region of a page. They connect the equivalent versions of the same content in different languages, so that Google shows the right version to each user.

What is the role of the HTML hreflang attribute in international SEO?

Its role is to tell the search engine which language and region each page serves, preventing it from showing the wrong version or treating the translations as competing duplicate content. It is what organizes a multilingual site in Google's eyes.

How do you implement hreflang on a site?

You can declare hreflang in three ways: with link tags in the HTML of each page, inside the XML sitemap or in the HTTP header (used for files like PDF). In any case, each page must point to itself and to the other versions, always with a mutual return.

What is the difference between hreflang and the canonical URL?

The canonical URL resolves duplicates in the same language by indicating the preferred version; hreflang connects versions in different languages or regions. Each page should have a canonical pointing to itself, never to the version in another language, so it does not conflict with hreflang.

What is the x-default value in hreflang?

The x-default is a special hreflang value that indicates the default page for users whose language or region has no specific version. It works, for example, as a fallback page or language selector for the rest of the world.

Sharp technical SEO, on autopilot

Automarticles writes and optimizes your blog articles on its own, taking care of the technical details and the content so your site ranks in every language.

Start free trial
Keep learning

Related concepts

Canonical URLA canonical URL is the preferred version of a page when several addresses hold identical or very similar content. It is signaled to the search engine by a canonical tag (rel=canonical) in the HTML or by other signals, telling it which URL should be treated as the original, the one that appears in search and concentrates the authority of the links. It is the main tool for solving duplicate content without deleting pages or harming the user experience.Technical SEOTechnical SEO is the set of optimizations made to a site's infrastructure so that search engines can crawl, understand, index and display its pages efficiently. While content takes care of what the page says, technical SEO takes care of the invisible foundation that supports everything: loading speed, URL structure, internal link architecture, mobile version, security, structured data, indexing and status codes. Without that foundation in order, even the best content may never appear in search.XML SitemapAn XML sitemap is a file in XML format that lists the important URLs of a site to help search engines discover, crawl and prioritize those pages. It works as a site map handed to Google, telling it which addresses exist and, optionally, when they were updated, which is especially useful on large, new sites or ones with pages poorly connected by internal links.IndexingIndexing is the process by which a search engine adds a page to its index, the huge database it consults to answer queries. After crawling and analyzing the content, Google decides whether to store the page in the index, and only what is indexed can appear in the results. In SEO, ensuring indexing is the mandatory step before any attempt to rank: a page outside the index is, in practice, invisible to searchers.