Home / Blog / Indexing and Crawling / How do you add hreflang tags, and what are the best practices?
Answers

How do you add hreflang tags, and what are the best practices?

16 October 2026 · By John Carlsson
You add hreflang by listing every language or regional version of a page, using HTML link elements in the head, an HTTP Link header or your XML sitemap. Each version must list itself and all others, links must be reciprocal, URLs must be fully qualified with https, codes must use ISO 639-1 with an optional ISO 3166-1 region, and x-default covers unmatched visitors.

What does hreflang do?

Hreflang tells Google that a page has other versions for different languages or regions, so it can show searchers the most suitable one. Google's localised versions documentation covers the rules in full. Google does not use hreflang or the HTML lang attribute to detect a page's language; it works that out with its own algorithms. Hreflang is about linking versions together.

Which method should you use to add hreflang?

Google supports three methods and treats them as equivalent:

Choose one. Google says there is no benefit in Search to using more than one method, and each extra method is another place to keep in sync. Google notes that link elements are useful if you do not have a sitemap or cannot set HTTP response headers.

How do you add hreflang tags in HTML?

In the head of every version, add a link element with rel="alternate", an hreflang code and an href for each version, including the page itself. For a page in British English, American English and German, with a fallback, each of the three pages would carry the same set:

<link rel="alternate" hreflang="en-GB" href="https://example.com/en-gb/page.html" />
<link rel="alternate" hreflang="en-US" href="https://example.com/en-us/page.html" />
<link rel="alternate" hreflang="de" href="https://example.com/de/page.html" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

The x-default value is reserved for the page users should see when no other version matches their browser settings, such as a language or country selector. It needs no language code.

What are the hreflang best practices?

Most hreflang problems come from a small set of rules. Follow these and the tags are far more likely to be used.

Make every link reciprocal

Each version must list itself and every other version. If page A points to page B, page B must point back to page A. Google says that if two pages do not both point to each other, the tags will be ignored.

Use valid language and region codes

The first part of the value is a language code in ISO 639-1 format, such as en or de. You may add a region in ISO 3166-1 Alpha 2 format, such as en-GB. A country code on its own is not valid, and a code such as be is read as a language, not a country. Codes such as es-419 are not supported.

Watch the region codes too. Google lists UK, EU and UN among codes that Google Search ignores. For the United Kingdom, use GB.

Use fully qualified URLs

Alternate URLs must include the protocol, for example https. Protocol-relative URLs such as //example.com/foo and root-relative URLs such as /foo are not accepted.

Keep the set consistent across versions

Every page in a group should carry the same list of alternates. When you add or remove a language version, update all the other pages in the group at the same time, or the return links will break.

How do you check your hreflang is working?

Open the page source of each version and confirm that the full set of alternates appears in the head, or check your sitemap or HTTP headers if you used those methods. Then confirm each URL listed returns a normal page and links back. The URL Inspection tool in Search Console shows how Google sees an individual page. Because the rules depend on every page in a group agreeing, check the whole set rather than one page at a time.

Sources

Frequently asked questions

Is en-UK a valid hreflang code?

No. The region part must be an ISO 3166-1 Alpha 2 code, and the code for the United Kingdom is GB, so use en-GB. Google says that using UK, EU or UN in hreflang annotations has no effect on Google Search. Using an invalid region code is one of the common mistakes in Google's hreflang documentation.

Does hreflang tell Google what language my page is in?

No. Google says it does not use hreflang or the HTML lang attribute to detect the language of a page, and uses its own algorithms instead. Hreflang tells Google which pages are alternate versions of each other, so it can show the most suitable version to searchers in each language or region.

💬 Got a problem?

aiwebpageseo.com is a data-driven SEO and AEO platform providing a free suite of technical website tools.