The hreflang tag is an HTML attribute used inside the link element to tell search engines and browsers the language and, optionally, the target geographic region of a given web page. Introduced by Google’s guidelines for multilingual and multi-country sites, this attribute lets you flag the alternative versions of the same page written in different languages, avoiding duplicate content problems and improving the user experience.

When a site has content in several languages or aimed at audiences in different countries, the hreflang tag becomes the main tool for telling search engines which version to show to which user. Without a correct implementation, an English page could show up in search results meant for German users, or two language versions could compete with each other and both lose ranking.

Where the hreflang tag goes

The hreflang tag goes in the head of the HTML document through the link element, setting the rel attribute to alternate and the hreflang attribute to the language code you want. Alternatively, the same signal can be sent through the HTTP header or through the XML sitemap.

The attribute value follows the ISO 639-1 standard for language and, when needed, the ISO 3166-1 Alpha 2 standard for region. For example, en means generic English, while en-GB specifies English for the United Kingdom. This distinction is essential for sites that differentiate content not only by language but also by market.

The reciprocal annotation between versions

The correct syntax requires every page in the multilingual group to list all the alternative versions, including itself. This mechanism, called “reciprocal”, is essential so that search engines can correctly interpret the relationships between pages.

The hreflang lines in the page metadata

A typical block of hreflang tags placed in the page metadata includes one line for each language version, with the absolute URL of the corresponding page and the appropriate language-region code. It is important that the URLs are complete and that every page points to the others symmetrically.

When the XML sitemap is the better choice

For large sites, adding hreflang tags to the XML sitemap is more manageable than inserting them by hand in the head of every page. In this case, each url element in the sitemap contains a series of link elements with the rel and hreflang attributes that point to the alternative versions.

Hreflang, lang and canonical: what changes

The hreflang tag is often confused with other indexing and localization tools. Understanding the differences is crucial so you don’t harm the site’s visibility on search engines.

Attribute or tag Main function Scope Effect on search engines
hreflang Indicates the language and region of an alternative page Multilingual and multi-country sites Serves the correct version to the right user
lang Declares the language of the page content Single HTML page Improves accessibility and speech synthesis
canonical Indicates the main version of a page Duplicate or similar content Concentrates SEO value on a single URL
rel alternate Links alternative versions of a resource Feeds, mobile versions Signals relationships between documents
Content-Language Specifies the language in the HTTP header Server responses Context information for the browser

The most common mistakes on multilingual sites

Incorrect implementation of the hreflang tag is one of the most frequent causes of indexing problems on international sites. Among the most widespread errors are the lack of reciprocity between pages, the use of invalid language codes and the use of relative instead of absolute URLs.

Check that the references are reciprocal

Every page in the group must list all the other versions, including itself. If page A points to page B but page B doesn’t point to page A, the signal is ignored. Analysis tools such as Google Search Console let you find errors of this kind.

Choose valid language and region codes

Using codes that the ISO standards don’t recognize means search engines ignore the tag. It’s good practice to check the official tables and stick to supported combinations. For content aimed at several countries that share the same language, such as English for the United Kingdom, the United States and Australia, you need to specify distinct regional codes.

From listing the versions to adding the tags

  1. Identify all the language and regional versions of the site that need annotation.
  2. Check that every page has a unique, accessible URL.
  3. Determine the appropriate language and region codes according to the ISO standards.
  4. Add the hreflang tags in the head of each page or in the XML sitemap.
  5. Make sure every page lists all the alternatives, including itself, reciprocally.
  6. Check that all URLs are absolute and correctly formatted.
  7. Validate the implementation with dedicated tools or through Search Console.
  8. Monitor for errors periodically and update the tags when you add new languages.

Frequently asked questions about the hreflang tag

Is the hreflang tag mandatory for multilingual sites?

It isn’t mandatory, but it is strongly recommended. Without it, search engines might show the wrong version to users or treat the pages as duplicate content.

What is the difference between hreflang and lang?

The lang attribute declares the language of a single page’s content, while hreflang links alternative versions of the same page in different languages or regions.

Can I use hreflang and canonical together?

Yes, it’s possible and sometimes recommended. The canonical tag indicates the main version, while hreflang flags the language alternatives. They must, however, be implemented consistently to avoid conflicts.

What happens if the hreflang tags aren’t reciprocal?

If a page doesn’t return the reference, the search engine ignores the signal. Reciprocity is a fundamental requirement for it to work correctly.

Can I put hreflang in the sitemap instead of the head?

Yes, the XML sitemap is a supported method and often preferred for sites with many pages, because it centralizes tag management.

Does the hreflang tag affect ranking?

It isn’t a direct ranking factor, but it improves the user experience and helps search engines serve the correct version, with indirect positive effects on visibility.

From the glossary to the projectWant to know if your site has technical problems holding back its visibility?The technical SEO audit reviews the site to find errors and ranking opportunities on Google and delivers a list of fixes in priority order.Discover the technical SEO audit

Related entries:

Multilingual website html Multilingual SEO H1 tag html HTML tag