The hreflang attribute is an HTML language element that tells search engines the language and, optionally, the geographic region targeted by a specific version of a web page. It is placed inside the link tag in the document head section or sent via the HTTP header or sitemap. Its main function is to solve duplicate content issues that arise when a site has multiple language or regional versions of the same page.
When a multilingual site publishes translated or adapted content for different markets, search engines might interpret these variants as duplicate pages and penalize them in results. Hreflang resolves this ambiguity by explicitly declaring that the different versions are alternatives to each other, not competitors. This way Google and other search engines can show users the most appropriate version based on their detected language and geographic location.
How hreflang works
Hreflang uses standardized codes to identify language and region. The language follows the ISO 639-1 standard, which uses two-letter codes like en for English, it for Italian, or fr for French. The region, optional, follows the ISO 3166-1 alpha-2 standard with two-letter uppercase codes like US for the United States or GB for the United Kingdom. The two codes are separated by a hyphen.
An attribute can specify only the language, for example hreflang=“en”, or language and region together, like hreflang=“en-US”. There is also the x-default value, which indicates the version to show when none of the others match the user’s preferences. This value is especially useful for sites that offer an international English version as a fallback.
Reciprocal annotations
Every page in a multilingual group must list all other versions, including itself. This mechanism is called reciprocal annotation and is essential: if page A points to page B but B does not link back, Google might ignore the entire signal. Annotations can be placed in the HTML code, in the HTTP header, or in a dedicated sitemap.
Difference between hreflang and other methods
There are several ways to manage multilingual and regional content, and each has specific characteristics. Hreflang does not replace actual content translation but signals it to search engines. It is important not to confuse it with other tools that serve different functions.
| Method | Main function | Directs search engines | Directs users |
|---|---|---|---|
| hreflang | Signals alternative language and regional versions | Yes | No |
| Redirect | Sends the user to another address | Partially | Yes |
| Language selector | Lets the user choose manually | No | Yes |
| Dedicated domain | Separates content by market or language | Yes | Yes |
| Machine translation | Converts content into another language | No | Yes |
Common implementation mistakes
Incorrect hreflang implementation is a frequent problem even on large sites. The most common mistakes include using invalid language codes, missing reciprocal annotations, and pointing to URLs that return errors or redirects. Including untranslated pages in the same language can also cause confusion.
Invalid codes
An incorrect language code, such as hreflang=“en-US-” with a trailing hyphen or a lowercase region code, can invalidate the entire annotation. It is essential to strictly follow ISO standards and verify every value entered.
Lack of reciprocity
If the English page points to the Italian one but does not receive the reverse reference, Google might discard the signal. Every group of pages must form a complete network of cross-references.
Best practices for hreflang
To achieve reliable results, it is advisable to follow some established guidelines. Consistency between declared URLs and actually reachable URLs is the first requirement. Additionally, each language version should have genuinely translated and adapted content, not simply duplicated with different labels.
- Verify that every page in the group lists all other versions, including itself.
- Use language and region codes compliant with ISO 639-1 and ISO 3166-1 alpha-2 standards.
- Ensure that declared URLs return valid status codes and not redirects.
- Include an x-default value to indicate the fallback version.
- Maintain consistency between HTML annotations, HTTP headers, and the sitemap.
- Avoid including untranslated pages in the same language within the group.
- Periodically check annotations to detect errors or broken links.
- Do not use hreflang as a substitute for actual content translation.
Frequently asked questions
What does hreflang mean?
Hreflang is an HTML attribute that indicates the language and target region of a web page, allowing search engines to show the version most suitable for the user.
Where is hreflang placed?
It can be placed in the head section of the HTML document, in the HTTP header of the server response, or in a sitemap dedicated to multilingual content.
What is the difference between hreflang and lang?
The lang attribute indicates the language of a page’s content, while hreflang signals alternative versions of the same page in other languages or regions.
Is hreflang mandatory for multilingual sites?
It is not mandatory, but it is strongly recommended to avoid duplicate content issues and improve the experience for international users.
What happens if hreflang is implemented incorrectly?
Search engines might ignore the annotations, showing users the wrong version or treating pages as duplicate content.
What is the x-default value?
It is a special hreflang value that indicates the page to show when none of the language or regional versions match the user’s preferences.
Related entries:
Hreflang tag Multilingual website html Multilingual SEO Localization Language targeting
