Hreflang is an annotation that tells Google a set of pages are the same content in different languages or for different regions, so it can show each searcher the right version. You add it as link tags, HTTP headers or sitemap entries. Every version must list itself and all the others.
What does hreflang actually do?
Hreflang maps your pages to their intended audiences. Google's guide to localized versions of your pages describes it as a way to tell Google that several pages are localized variations of the same content, so Search can show the most appropriate one.
It does not translate anything, and it does not decide a page's language. Google says it does not use hreflang or the HTML lang attribute to detect a page's language. It uses its own systems for that. Hreflang only tells Google which version is meant for whom.
Do you need hreflang?
Use this quick test. You need hreflang when the same content exists in more than one version aimed at different people:
- Different languages. An English page and its Spanish translation.
- Same language, different regions. A US page and a UK page that differ in currency, spelling or shipping terms.
You do not need it for a single-language site, or for a site where you only translate some pages and the rest have no equivalent. Google notes that localized pages are only treated as duplicates when the main content stays untranslated, which is a separate problem covered in duplicate content and how to fix it.
What are the three ways to add it?
| Method | Where it goes | Best when |
|---|---|---|
| HTML link tags | In the <head> of each page | You can edit page templates and have a small number of versions |
| HTTP Link header | In the server response | The file is not HTML, such as a PDF |
| XML sitemap | As xhtml:link entries per URL | You have many pages and want one place to maintain it |
Google treats the three methods as equivalent, and using more than one adds nothing in Search. Pick one and keep it consistent. If you already maintain a sitemap, see how to submit a sitemap to Google.
What does a correct example look like?
A page available in English for the US, English for the UK and Spanish, with a fallback, would carry this block in every one of its versions:
<link rel="alternate" hreflang="en-us" href="https://example.com/en-us/pricing" /> <link rel="alternate" hreflang="en-gb" href="https://example.com/en-gb/pricing" /> <link rel="alternate" hreflang="es" href="https://example.com/es/pricing" /> <link rel="alternate" hreflang="x-default" href="https://example.com/pricing" />
The same four lines go on all of those pages, not just the English one. That is the single most important thing to get right.
What are the rules that trip people up?
- Self-reference. Each version must list itself as well as the others.
- Return links. If page A points to page B, page B must point back to A. Google says the annotations may be ignored otherwise.
- Full URLs. Use the complete address with protocol, such as
https://example.com/foo, not/foo. - Valid codes. Use a language code (ISO 639-1), optionally followed by a region code (ISO 3166-1 Alpha 2). A region code cannot stand alone, so
usis wrong anden-usis right. Made-up codes such asUKfor the language orEUfor a region have no effect. - x-default. Add it for the page that serves everyone whose language matches none of your versions, such as a country selector.
- Match your canonicals. Each version should be its own canonical, not point at another language. See canonical URLs.
Which structure should you pick for the URLs?
Hreflang works with any structure that gives each version its own URL: separate domains, subdirectories such as /es/, or subdomains. Google notes that a subdomain label like en-gb does not by itself tell it the audience, so you still need the annotations. For a small site, subdirectories are the simplest to run, because everything lives on one domain and one sitemap. Avoid serving different languages from the same URL based on a cookie or browser setting, since a crawler then sees only one version.
How do you check that it works?
Take one URL and open each version. Confirm every version lists all the others, including itself, and that each listed URL returns a normal page rather than a redirect or error. Then spot-check a few more. Most hreflang failures are broken symmetry: a new page was added to the English set but the older pages were never updated to point at it. Generating the tags from one source of truth, such as your sitemap or a template, prevents that.
Does hreflang matter for AI search?
Google says its AI features rely on the same indexing and eligibility foundations as normal Search, per its guide to AI features and your website. There is no published statement that ChatGPT or Perplexity read hreflang, so treat it as a Google Search tool and do not expect it to steer AI answers.
Frequently Asked Questions
Is hreflang a ranking factor?
No. It does not make a page rank higher. It helps Google pick which of your existing versions to show a given searcher.
Can I use hreflang across different domains?
Yes. Alternate URLs do not need to share a domain, as long as each one lists the full set and links back.
What is x-default for?
It marks the fallback page for users whose language or region matches none of your versions, often a language selector or your main version.
Should I put hreflang in the sitemap and in the head?
One method is enough. Google treats them as equivalent, so choose the one that is easiest for you to keep accurate.
What happens if I get it wrong?
Google may ignore the annotations and choose versions on its own, so searchers can land on the wrong language. It does not usually cause a penalty.