What is hreflang and how to use it on a multilingual site

How to tell Google about your language versions, step by step: URL structure, the three methods, language codes, return links, x-default and canonical.

· 12 min readSEO

Short answer

hreflang is the annotation that tells Google the addresses of a page’s other language or region versions. Each version sits at its own address, lists itself and every other version, and links back reciprocally. Choosing one of the HTML, HTTP header or sitemap methods is enough.

Picture this: you have just published the English version of a Turkish service site, and every page is ready. Even so, someone searching in Turkish may get an English page and someone searching in English a Turkish one, because Google may not have linked the two pages as language versions of the same page. hreflang is the annotation that makes that link. What is hreflang and how do you use it on a multilingual site? We follow the steps in order below; the examples use only example.com.

Google calls a site that offers content in more than one language multilingual, and a site that explicitly targets users in different countries multi-regional; a site can be both. According to its documentation, the aim is to help Google Search take the user to the version that best fits their language or region. The same documentation says Google may find your language versions even if you do nothing, but that stating them explicitly is usually best.

What hreflang does and does not do

hreflang links the localised versions of the same content to each other. According to Google, localised versions are treated as duplicates only if the main content of the page stays untranslated; if you translate the menu and leave the body in one language, the content is a duplicate.

There are things it does not do either. Google does not detect a page’s language from hreflang or from the HTML lang attribute; it looks at the visible content of the page and determines the language with algorithms. So each page should keep its content and navigation in one language, with no side-by-side translations. hreflang does not translate anything, and we did not read in these pages that it guarantees rankings. Our reading: hreflang is not a ranking switch but a help for showing the right version to the right person.

Step 1: give each language its own address

Google recommends giving each version its own URL rather than changing the content with cookies or browser settings. It also writes that if you change content dynamically or redirect users, Google might not find and crawl all your variations: Googlebot usually comes from the USA and sends its requests without an Accept-Language header.

The documentation lists four options for a URL structure that makes geotargeting easier. The table summarises the pros and cons Google gives for each.

Structure Example Pros listed by Google Cons listed by Google
Country-specific domain example.de Clear geotargeting, server location irrelevant, easy to separate sites Expensive (can have limited availability), needs more infrastructure, strict ccTLD requirements (sometimes), can only target a single country
Subdomain de.example.com Easy to set up, different server locations possible, easy to separate sites Users might not recognise geotargeting from the URL alone (is “de” the language or the country?)
Subdirectory example.com/de/ Easy to set up, low maintenance (same host) Users might not recognise geotargeting from the URL alone, single server location, separation of sites harder
URL parameter example.com?loc=de None listed; it says “not recommended” URL-based segmentation difficult, users might not recognise geotargeting from the URL alone

This article uses the subdirectory structure: https://example.com/tr/ and https://example.com/en/. hreflang works with each structure. Having “en” or “de” in the address does not define the target audience: in Google’s example, the language parts of subdomains are not used for that; you have to map the audience explicitly with hreflang. Localised words in the URL and Internationalised Domain Names are allowed, as long as you use UTF-8 and encode the addresses properly when you link to them. If you have not yet decided which system will run the site, see our article on choosing a CMS. If you are changing the URL structure of an existing site, that is a separate migration project: our article on SEO when changing your domain name covers it. For URL structure, the language switcher and translation decisions, see how to build a multilingual website.

Step 2: choose one of three methods

Google lists three ways to declare page versions: HTML, an HTTP header and a sitemap. According to the documentation, the three are equivalent from Google’s side; using all of them at once brings no benefit in Search, and three implementations may be harder to manage. The rules common to all three are:

  • Each language version lists itself and every other version.
  • Addresses are written in full, with the protocol: https://example.com/en/ is right, /en/ is wrong.
  • The alternate addresses do not need to be on the same domain.

HTML. Google says this method is useful if you have no sitemap or no way to set HTTP headers. In the <head> of each version you put one <link> line per version, itself included; the set is the same on every page.

<link rel="alternate" hreflang="tr" href="https://example.com/tr/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />

The tags must sit inside a well-formed <head>. Do not combine hreflang with another attribute such as media in the same <link> tag.

HTTP header. Useful for non-HTML files, such as PDFs. The response for every version returns the same Link: header, with the versions separated by commas. Here is an example for a Turkish and an English PDF version:

Link: <https://example.com/tr/katalog.pdf>; rel="alternate"; hreflang="tr", <https://example.com/en/catalog.pdf>; rel="alternate"; hreflang="en"

Sitemap. In each <url> entry you list every version of the page, itself included, with xhtml:link. An example with two versions:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://example.com/tr/</loc>
    <xhtml:link rel="alternate" hreflang="tr" href="https://example.com/tr/"/>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/"/>
  </url>
  <url>
    <loc>https://example.com/en/</loc>
    <xhtml:link rel="alternate" hreflang="tr" href="https://example.com/tr/"/>
    <xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/"/>
  </url>
</urlset>

The general sitemap rules apply here too; we covered how to prepare one in our article on robots.txt and sitemaps.

Step 3: write language and region codes correctly

The value can have two parts: a language code in ISO 639-1 format, then optionally a region code in ISO 3166-1 Alpha 2 format, separated by a hyphen. Only codes from these two lists are supported; codes outside them, such as es-419, are not.

  • tr: Turkish content, independent of region.
  • en-GB: English for users in the UK. Google is not case-sensitive, but writing the region code in uppercase follows the standard.
  • de-BE: German for users in Belgium.

Google’s documentation treats a region code on its own as invalid: the first code stands for the language, and Google does not derive the language from a country code. If you write be, as in its example, you have written the Belarusian language code. Codes reserved for something else, such as UK, EU and UN, have no effect in Google Search; the right value for the United Kingdom is en-GB. If you have separate English pages for Ireland, Canada and Australia, it is a good idea to also provide a generic en page for the US, the UK and other English-speaking places; it can be one of the specific pages. What this rule means for a site aimed at North Cyprus is covered in the hreflang section of our guide to targeting ads to North Cyprus.

If you would rather not write the codes by hand, our hreflang tag generator checks the code format and builds the block of tags.

If page A points to B, B must point back to A. According to Google, if two pages do not point to each other the tags are ignored; the reason is that another site cannot declare itself an alternate of your page. Giving the same set on every page satisfies this rule automatically.

If keeping a full two-way network for every language becomes hard, Google allows you to leave some languages out on some pages; it will still process the ones that point to each other. It is more important, though, to link newly added language pages in both directions with the languages the site started in.

Step 5: name a fallback page with x-default

Use x-default to name the page shown when no language matches. Google recommends a fallback page especially for language selectors and auto-redirecting home pages; no language code is written for the value. The set grows to three lines and stays the same on every page:

<link rel="alternate" hreflang="tr" href="https://example.com/tr/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />
Three pages carry the same hreflang set: the Turkish page, the English page and the language selector link to each other both ways Language selector example.com/ x-default Turkish page example.com/tr/ hreflang="tr" English page example.com/en/ hreflang="en" Every page carries the same 3 lines: itself and the other two Three pages carry the same hreflang set: the Turkish page, the English page and the language selector link to each other both ways Turkish page example.com/tr/ hreflang="tr" English page example.com/en/ hreflang="en" Language selector example.com/ x-default Every page carries the same 3 lines: itself and the other two
Figure: Each of the three pages carries the same three lines and links to the other two; a link that stays one-way is ignored.

Step 6: use hreflang and canonical together

Neither replaces the other. According to Google’s canonical documentation, if you use hreflang, each page’s canonical should be in the same language, or the best possible substitute language if none exists in that language. The canonical page should also carry a self-referencing rel="canonical". The documentation also says that rel="canonical" annotations with an hreflang attribute are not used for canonicalisation, and that rel="alternate" hreflang should be used for language and country. Our inference: do not point the English page’s canonical at the Turkish page; according to the localisation documentation, language versions are duplicates only if the main content stays untranslated.

The <head> of the English page looks like this:

<link rel="canonical" href="https://example.com/en/" />
<link rel="alternate" hreflang="tr" href="https://example.com/tr/" />
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />

If a multi-regional site serves similar or duplicate content in the same language on different URLs, Google says to pick a preferred version and use rel="canonical" and hreflang together. It also writes that when choosing a canonical it prefers addresses that are part of a reciprocal hreflang set.

Step 7: automatic redirects and machine translation

Google recommends that you do not automatically redirect users from one language version to another, for example by guessing the user’s language; such redirects could prevent users and search engines from seeing all the versions. Its advice is to link to the other language versions. It also says not to adapt content by IP analysis: IP location analysis is difficult and generally not reliable, and most but not all Google crawls come from the US, with no attempt to vary the location to find variations. The documentation adds that geotargeting is not an exact science and suggests showing links for choosing a region and language for users who land on the wrong version. Our suggestion is to put that link in the top bar or the footer.

Google’s spam policies give a yardstick for machine translation. According to the policy, when many pages are generated for the primary purpose of manipulating rankings and not helping users, that is “scaled content abuse”. Its examples include using generative AI tools to generate many pages without adding value for users, and multiplying scraped content through automated transformations such as translating. We saw no separate item for the translation of your own content. The practical conclusion is our suggestion: treat machine translation as a draft, have someone who knows the language read every page, and do not bulk-translate and publish the whole site in one go.

Step 8: check the result

  1. Page source. Search for hreflang in each language version. The number of lines should equal the number of versions (one more if you gave x-default), the set should be the same on both pages, and the addresses should be written in full.
  2. Header. If you used the header method for files such as PDFs, run curl -I https://example.com/en/catalog.pdf in a terminal and look for the Link: line in the response.
  3. Sitemap. Open the file and check that every <url> entry lists all the versions, the page itself included.
  4. Search Console. Where it describes the “Alternate page with proper canonical tag” status, the help page for the page indexing report states that Search Console does not detect alternate language pages. Our inference: do not expect to read the pairing of your language versions from this report.
  5. Third-party tools. Google’s documentation says there are third-party tools for debugging, and that they are not maintained or checked by Google.

For the rest of a technical audit, the sixth step of our technical SEO checklist covers hreflang on two-language sites.

Common mistakes

  • Translating only the menu and footer. Google writes that translating the boilerplate while keeping the bulk of the content in one language can mean the same content appears again and again in search results with different boilerplate languages, which is a bad experience.
  • Putting HTTP addresses in the set or the sitemap. To stop Google from wrongly making the HTTP page canonical, Google says not to include the HTTP version in hreflang or the sitemap instead of the HTTPS version.
  • Linking a new language only to other new languages. The pages you add should be linked in both directions with the pages in the site’s first language, which are the strong ones.
  • Forgetting the tags when addresses change. Our warning: if a page moves, its address in the set changes too; a tag whose counterpart is left at the old address is a broken link.

Common questions

Should I give hreflang in both HTML and the sitemap?

No. According to Google’s documentation the three methods are equivalent and using all of them brings no benefit in Search. Pick the easiest one for you and keep it in one place.

Is x-default required?

The documentation says x-default is recommended, not that it is required. If you have a page to show when no language matches, especially a language selector or an auto-redirecting home page, add it.

Can I write only a country code?

No. Google treats a region code on its own as invalid; the first value has to be the language. For Türkiye write tr, and for German speakers in Türkiye write de-TR.

One thing you can do today

Open the source of the Turkish and English versions of your home page and search for hreflang. You should see the same set on both pages, itself included, with full addresses. If you do not, add the block from step 2.

If you are building a multilingual site, or opening an existing one to new languages, in our SEO service we do keyword research for each language in that language. We mark language and country versions with hreflang and keep each language’s pages at its own address.

Sources

This article is general information, not legal, financial or technical advice. Platforms, their rules and the law change over time, so some details may have changed since 14 November 2026 or contain small errors. Before you make a decision for your business, check the current official sources or write to us.

Tell us about
your project.

Fill in the form or write to us directly, and we will agree on a day to talk.

Your first meeting is with Deniz Sezer, founder of Detmore.

First meeting free · Reply within one working day · Written proposal in 2 to 3 days · NDA ready

What do you need? pick as many as you like

Name, email and phone are required.

Contact

We reply within one working day.