Skip to content

Search

Articles, tools, solutions and knowledge base guides

Start typing to search across articles, tools and apps.

Hreflang: how to implement multilingual SEO correctly

A Polish visitor lands on an English pricing page from Google even though a Polish equivalent exists. Translating the page alone does not solve this problem. You need distinct URLs, coherent indexing signals and explicit relationships between equivalents. This guide explains how to design, implement and validate hreflang on a multilingual website.

Published Written by Reading time 10 min read
On this page Contents: quick navigation between sections

What does hreflang do and what does it not do?

Hreflang helps Google match a content variant to the audience's language and optionally region. It is not an indexing directive or a ranking guarantee. It cannot replace localization, and Google identifies language primarily from visible content. The lang attribute on the html element serves a different purpose, including assistive technology support. [1][2][7]

Connect pages that satisfy the same need: link a Polish pricing page to its English equivalent, not the English homepage. Differences in currency, delivery or taxes make sense when serving different markets.

Language, region and x-default

The code pl means Polish regardless of country, en-GB means English for the United Kingdom, and zh-Hant means Chinese in traditional script. For Ukraine the language is uk and the region is UA. Use en-GB rather than en-UK, and never use a country code alone. Create regional variants only when there is a genuine localization need. [1]

X-default is an optional fallback for unmatched audiences. It can point to a global language selector for that content or an existing generic variant. It is neither a redirect nor a language code. If it points to a separate URL, include that URL in reciprocal-link checks.

Google documents ISO 639-1 language codes, ISO 3166-1 alpha-2 region codes and ISO 15924 scripts. Not every locale accepted by an i18n library is supported by Google. For example, en-EU is not valid EU targeting. If en-US and en-GB exist, consider a generic en variant as well; x-default serves unmatched audiences instead. [1]

How to design URLs and language selection

Subdirectories on one domain simplify shared infrastructure. Subdomains allow independent deployments, while country domains may suit independent markets. Google discourages using language parameters as the primary site structure. A URL prefix alone does not establish alternate relationships. [2]

Give each translation a stable URL accessible without cookies. Use browser language detection for suggestions or a neutral entry point, rather than overriding an explicit locale URL. The language switcher should link to the equivalent with a regular hyperlink; a CDN must not serve Polish HTML at an English URL due to an incorrect cache key. Crawlers may miss variants dependent on request headers or location. [3][8]

Equivalents may reside on separate domains, such as example.pl and example.de. Each domain must publish consistent return links. For sitemaps, check submission permissions and the scope of loc entries for each file; alternate targets may reside on other domains. Neither directory nor domain structure replaces hreflang. [1][2][9]

Three ways to implement hreflang

MethodUse caseWhere to check
HTMLHTML pagesDocument source
HTTP LinkPDF documentsHTTP response
XML sitemapLarge catalogsSitemap file

HTML example: Polish version

<!doctype html>
<html lang="pl">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Cennik</title>
    <link rel="canonical" href="https://example.com/pl/cennik" />
    <link
      rel="alternate"
      hreflang="pl"
      href="https://example.com/pl/cennik"
    />
    <link
      rel="alternate"
      hreflang="en"
      href="https://example.com/en/pricing"
    />
    <link
      rel="alternate"
      hreflang="x-default"
      href="https://example.com/en/pricing"
    />
  </head>
  <body>
    <main>
      <h1>Cennik</h1>
      <nav aria-label="Wybór języka">
        <a
          href="/pl/cennik"
          lang="pl"
          hreflang="pl"
          aria-current="page"
          >Polski</a>
        <a href="/en/pricing" lang="en" hreflang="en">English</a>
      </nav>
    </main>
  </body>
</html>

HTML example: English version

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Pricing</title>
    <link rel="canonical" href="https://example.com/en/pricing" />
    <link
      rel="alternate"
      hreflang="pl"
      href="https://example.com/pl/cennik"
    />
    <link
      rel="alternate"
      hreflang="en"
      href="https://example.com/en/pricing"
    />
    <link
      rel="alternate"
      hreflang="x-default"
      href="https://example.com/en/pricing"
    />
  </head>
  <body>
    <main>
      <h1>Pricing</h1>
      <nav aria-label="Language selection">
        <a href="/pl/cennik" lang="pl" hreflang="pl">Polski</a>
        <a
          href="/en/pricing"
          lang="en"
          hreflang="en"
          aria-current="page"
          >English</a>
      </nav>
    </main>
  </body>
</html>

HTTP Link header for both PDF files

Link: <https://example.com/pl/poradnik.pdf>; rel="alternate"; hreflang="pl", <https://example.com/en/guide.pdf>; rel="alternate"; hreflang="en"

XML sitemap with both variants

<?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/pl/cennik</loc>
    <xhtml:link
      rel="alternate"
      hreflang="pl"
      href="https://example.com/pl/cennik"
    />
    <xhtml:link
      rel="alternate"
      hreflang="en"
      href="https://example.com/en/pricing"
    />
    <xhtml:link
      rel="alternate"
      hreflang="x-default"
      href="https://example.com/en/pricing"
    />
  </url>
  <url>
    <loc>https://example.com/en/pricing</loc>
    <xhtml:link
      rel="alternate"
      hreflang="pl"
      href="https://example.com/pl/cennik"
    />
    <xhtml:link
      rel="alternate"
      hreflang="en"
      href="https://example.com/en/pricing"
    />
    <xhtml:link
      rel="alternate"
      hreflang="x-default"
      href="https://example.com/en/pricing"
    />
  </url>
</urlset>

For HTML, place alternate links in a valid head. Each variant should reference itself and its equivalents, using absolute HTTPS URLs. In the fictional example below, Polish and English pages have their own canonical URLs, while x-default points to the existing English variant.

For PDFs use the HTTP Link header; for large catalogs an XML sitemap may be easier to maintain. Google treats all three methods equally. Choose the one you can maintain consistently, since duplicating declarations provides no additional benefit. [1][5][9]

In the HTTP example, both PDFs return the identical Link value in their GET responses. For HTML, inspect the parsed head, not merely the presence of text in the source. Do not combine hreflang with a media attribute in one link element. [1][5]

Canonical, noindex and missing translations

Distinct indexable translations should be self-canonical. Making the English version canonical for the Polish translation can undermine its independent indexing. For genuine same-language duplicates, select a preferred version under your canonical policy and reconcile it with hreflang. Canonical is a hint, not a guaranteed selection. [4]

Keep working, indexable equivalents in the target group. Do not advertise a 404, noindex or redirected URL as an available translation. If the German article does not exist, omit de across the group rather than substituting the homepage. Robots.txt does not replace noindex, and blocking crawling can prevent declarations from being read. [10]

Distinguish a translation from a regional duplicate. If US and Canadian English pages have materially different offers, each can have its own canonical; if they are genuine duplicates, choose a preferred version in the same language. Do not force self-canonicalization on every duplicate merely because it has a region. [2][4]

Generating declarations in CMS, SSR and SSG

Store translation groups by stable content ID, not similar slugs. Keep each variant's locale, final URL, publication status and indexing policy. Generate declarations from the same data source as language navigation and sitemaps. Publishing a translation updates the entire group, not just the new document.

With SSR and SSG, generate metadata on the server or at build time. For CSR inspect the rendered DOM too, without relying on user interaction. With ISR invalidate all affected pages and the sitemap, not just the new variant. Test responses without cookies and with different Accept-Language headers. [6]

Release example: publishing a translation for the pricing group requires refreshing all its documents and sitemap. When retiring a translation, first decide the old URL's HTTP response (redirect only to a genuine equivalent, or return 404/410), then remove its annotations across the group. Annotation URLs should be final destinations without tracking parameters.

A step-by-step hreflang audit

Export published URLs and group IDs from the CMS. Fetch HTTP responses, retaining initial and final URLs. Extract canonical, robots, alternate declarations in head or headers, and sitemap relationships. For every A → B pair, check that B points back to A with the right code. Separately detect conflicting destinations per code, missing self-references, wrong languages and mismatched sources.

Example: 120 articles in three languages yield 360 URLs and 1,080 language declarations including self-references (excluding x-default). If 12 German pages lack return links, fix generation for all 12 groups instead of patching individual documents. Complete sets are a useful engineering acceptance criterion even though Google can process some valid reciprocal pairs. [1]

Acceptance criteria: for each group with at least two variants, compare its language–URL pairs with approved CMS records. Verify status 200, no redirects or indexing blocks, canonical consistency with group policy and one target per code. Allow the same URL for distinct codes when intentional, such as en and x-default. Repair missing return links at both ends; do not discard unrelated valid pairs just because one pair is broken. [1][4]

Search Console diagnosis and release acceptance

If a Polish query leads to an English result, first check whether the Polish URL is indexed, whether Google selected the intended canonical and whether its content is actually Polish. Next check return links and final destinations. URL Inspection is not a full hreflang-group validator; the live test cannot predict Google's canonical selection. [11]

In CI reject changes that break locale mappings, reciprocal links or destination consistency. After release compare impressions and clicks by page group and country before and after recrawling. Country in the report is not the user's language. Do not attribute growth to hreflang alone without accounting for content changes and seasonality. [12]

Search Console's International Targeting report has been retired. Do not look there for hreflang errors or country targeting settings. Use URL Inspection, Performance and your own group crawler instead. After a change, check the last crawl date: a current live test does not mean Google has processed all the relationships. [16][11]

POLPROG, Sitemaps and robots.txt [13]

Meta tag generator [14]

Frontend internationalization (i18n) [15]

A meta tag generator helps prepare declarations but cannot independently establish the status of every destination. In production combine generation with checks of actual HTTP responses. The robots.txt and sitemap.xml guide covers URL discovery and indexing in more detail.

Effective multilingual SEO starts with accessible, properly localized pages. Hreflang connects them into groups, but its usefulness depends on indexability, coherent canonical signals and maintaining relationships during releases. A robust process detects inconsistencies before publication and verifies actual URLs after deployment.

Tools for this topic

Hreflang Multilingual SEO International SEO Technical SEO Canonical URL XML Sitemap Localization Google Search Console SSR x-default

Frequently asked questions

Is hreflang mandatory?

No. It is useful when language or regional equivalents exist. Missing declarations do not automatically prevent indexing.

Does hreflang improve rankings?

It does not guarantee ranking gains. It helps match a suitable variant to the audience.

Can I use en and en-GB together?

Yes, when a generic English version and a UK-specific version exist.

Is x-default required?

No. Add it when a meaningful fallback exists.

Must every page be translated?

No. Declare only actual equivalents of that content.

Must all three methods be implemented?

No. One correct, maintainable method is enough.

Sources and references

  1. Google Search Central, Localized versions of your pages↩1↩2↩3↩4↩5↩6↩7↩8
  2. Google Search Central, Managing multi-regional and multilingual sites↩1↩2↩3↩4
  3. Google Search Central, Locale-adaptive pages↩
  4. Google Search Central, Canonical URLs↩1↩2↩3
  5. RFC 8288, Web Linking↩1↩2
  6. Google Search Central, JavaScript SEO basics↩
  7. W3C, Declaring language in HTML↩
  8. Google Search Central, Link best practices↩
  9. Google Search Central, Build and submit a sitemap↩1↩2
  10. Google Search Central, Block indexing with noindex↩
  11. Google Search Console, URL Inspection↩1↩2
  12. Google Search Console, Performance report↩
  13. POLPROG, Sitemaps and robots.txt↩
  14. POLPROG, Meta tag generator↩
  15. POLPROG, Frontend internationalization (i18n)↩
  16. Google Search Console, The International Targeting report is deprecated↩

Was this helpful?

Get new articles by email

One short email per new Learning article. No spam, unsubscribe in one click.

We only use your email to send new articles. No third-party sharing.

Back to Learning