Skip to content
Arrampa
Language: EN, English
Join

Hreflang step by step: how to mark it up without mistakes

Hreflang is an annotation that tells Google which pages are versions of the same page in other languages or regions. It works if each version lists all of them, itself included, and they all link back to each other. Here is how to do it on a Swiss website and how to check it’s right.

The Arrampa team · IOZZIA Studio · Updated 17.11.2026 · 7 min read

What hreflang does and doesn’t do

Hreflang tells Google that two or more URLs are the same page in different languages or regions, so it can show each person theirs. Someone searching in French from Lausanne should see ejemplo.ch/fr/, not ejemplo.ch/de/.

Hreflang doesn’t tell Google which language a page is in. Google works that out from the visible text and uses neither hreflang nor the lang attribute for it. So the basics come before hreflang: one URL per language and a single language on each page.

Google ignores location meta tags such as geo.position. There’s no need to add them.

The codes: language and, optionally, region

The hreflang value is an ISO 639-1 language code, optionally followed by a hyphen and an ISO 3166-1 alpha-2 region code. For a Swiss website, these are the usual ones:

CodeWho it’s for
de-CHGerman readers in Switzerland
fr-CHFrench readers in Switzerland
it-CHItalian readers in Switzerland
rm-CHRomansh readers in Switzerland
enEnglish readers, in any country
deGerman readers, in any country
x-defaultAnyone who doesn’t fit any of the above

Worth knowing about the codes:

  • A country on its own doesn’t work. “CH” is not a valid value.
  • Lower-case “ch” isn’t Switzerland either: it’s the language code for Chamorro, a language of the Mariana Islands.
  • Upper or lower case doesn’t matter (de-ch works), but the region in capitals is the usual form.
  • Google ignores the region part if you use codes that aren’t countries, such as EU, UN or UK. For the United Kingdom it’s en-GB.

The three ways to mark it up

You can declare hreflang in the HTML, in the HTTP header or in the XML sitemap. For Google the three are equivalent, and using several at once adds nothing. Choose the one that suits your website best and stick to it.

MethodWhen to use itWatch out for
Link tags in the HTML headSmall or medium-sized websites; each page carries its own blockEvery new version means editing all the others
HTTP Link headerFiles that aren’t HTML, such as a PDF price listIt’s configured on the server
XML sitemapLarge websites or ones with many versionsIt has to be kept up to date and submitted to the search engines

Step by step with tags in the HTML

Here is a typical case: a .ch website with four languages in subfolders. Each page carries a block with all the versions in its head.

  1. List the versions of each page. For example, the prices page exists at /de/preise/, /fr/tarifs/, /it/tariffe/ and /en/prices/.
  2. Choose the code for each version: de-CH, fr-CH, it-CH and en.
  3. Decide which page gets x-default. Google suggests it for language selectors; if you don’t have one, point it at the version that best serves visitors from elsewhere.
  4. Write the block with full URLs, including https://, and include the page itself.
  5. Put the same block on all four versions. The page content changes; the list doesn’t.
<link rel="alternate" hreflang="de-CH" href="https://ejemplo.ch/de/preise/" />
<link rel="alternate" hreflang="fr-CH" href="https://ejemplo.ch/fr/tarifs/" />
<link rel="alternate" hreflang="it-CH" href="https://ejemplo.ch/it/tariffe/" />
<link rel="alternate" hreflang="en" href="https://ejemplo.ch/en/prices/" />
<link rel="alternate" hreflang="x-default" href="https://ejemplo.ch/en/prices/" />

If the block comes from a template that reads the list of versions, it’s almost impossible to forget a return link. Written by hand on every page, it’s easy.

With a sitemap or an HTTP header

In the sitemap, each URL carries its versions as xhtml:link elements. The full block is repeated inside each entry, including the URL itself.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://ejemplo.ch/de/preise/</loc>
    <xhtml:link rel="alternate" hreflang="de-CH" href="https://ejemplo.ch/de/preise/" />
    <xhtml:link rel="alternate" hreflang="fr-CH" href="https://ejemplo.ch/fr/tarifs/" />
    <xhtml:link rel="alternate" hreflang="it-CH" href="https://ejemplo.ch/it/tariffe/" />
    <xhtml:link rel="alternate" hreflang="en" href="https://ejemplo.ch/en/prices/" />
    <xhtml:link rel="alternate" hreflang="x-default" href="https://ejemplo.ch/en/prices/" />
  </url>
  <!-- Repeat the block in the entries for /fr/tarifs/, /it/tariffe/ and /en/prices/ -->
</urlset>

A PDF has no head to put tags in. For those files, use the HTTP Link header, which the server sends along with the file:

Link: <https://ejemplo.ch/docs/tarife.pdf>; rel="alternate"; hreflang="de-CH", <https://ejemplo.ch/docs/tarifs.pdf>; rel="alternate"; hreflang="fr-CH"

Self-references, return links and x-default

Three rules hold the whole system together, and they’re worth going through one by one.

  • Self-reference: the /fr/tarifs/ page includes its own link with fr-CH. Without it, the list is incomplete.
  • Return links: if /de/preise/ points to /fr/tarifs/, then /fr/tarifs/ has to point to /de/preise/. If either one is missing, Google ignores that pair.
  • x-default: the option for people searching in a language that isn’t on your list. Google suggests it for language selectors and for home pages that redirect based on the visitor.

Not every page has to exist in every language. If an article is only in German and French, its block lists those two versions, plus x-default if you like. Google processes the pairs that do link to each other.

When you publish a new version, link it first, both ways, with the version it comes from; usually the one in your main language. That’s what Google recommends.

Hreflang and canonical, together

Each version needs a canonical in its own language, usually itself. If every language points its canonical to the German version, you’re telling Google the French is a copy of the German, and that clashes with the hreflang.

Google puts it this way: the canonical has to be in the same language or, if there isn’t one, in the closest substitute. And a canonical tag with an hreflang attribute doesn’t work for canonicalisation. For the versions, use rel="alternate".

There is one special case: two versions in the same language for different countries, such as de-CH and de-DE. If they’re almost identical, Google recommends choosing a preferred version and using canonical and hreflang so each person sees the URL for their region. Better still: make them genuinely different, with each country’s prices, contact details and vocabulary.

How to check it’s right

Search Console no longer has the International Targeting report, so the checking is up to you. Google still uses hreflang, but today it has no dedicated report to warn you about mistakes.

  1. Open the source code of each version and look for the rel="alternate" links. The list has to be the same on all of them.
  2. For PDFs or headers, look at the server response in your browser’s developer tools or with curl -I.
  3. Open each URL on the list. It should respond without redirecting and be its own canonical.
  4. Check the codes one by one: no country on its own, no “ch” and no “UK”.
  5. If you use a sitemap, check that it has been submitted in Search Console and Bing Webmaster Tools, and that each entry repeats the full block.
  6. On large websites, run a crawler that cross-checks the versions and lists the links with no return link.

Arrampa’s audit, which we use in-house today, runs 14 hreflang checks on every crawl, including the HTTP header and the sitemap, and flags any page that doesn’t declare the lang attribute. It will open to clients later.

The most common mistakes

These mistakes appear in Google’s documentation or break the logic of the pairs:

MistakeConsequenceFix
Missing return linkGoogle ignores that pairThe same block on every version
Missing self-referenceThe list doesn’t follow Google’s ruleAlways include the page itself
Relative URLs (/fr/tarifs/)Not valid: they have to be full URLshttps://ejemplo.ch/fr/tarifs/
Country only (“CH”)Invalid codefr-CH
“en-UK”Google ignores the regionen-GB
Canonical pointing to another languageThe signals contradict each otherCanonical in the same language
Hreflang pointing to URLs that redirectThe signals contradict each otherPoint to the final URL

What about Bing?

Bing’s webmaster guidelines don’t mention hreflang. What they do ask for works just as well on a multilingual website: sitemaps with canonical URLs only, IndexNow notifications when something changes and a single URL for each piece of content.

So beyond the tag, each version needs its own URL, its own canonical and a clear language in the text itself. Submit the same sitemap to Google and Bing so both see all your versions.

FAQ

Do I have to add x-default?

It isn’t mandatory. It’s for people searching in a language you don’t offer. If you have a language selector or a home page that redirects, that’s where it belongs.

Can I combine tags and a sitemap?

You can, but you gain nothing: for Google they’re equivalent. If you do, both lists have to say the same thing.

Does hreflang replace the lang attribute?

No. Hreflang links versions; the lang attribute declares the page language for browsers and screen readers. Use both.

Which code do I use for English in Switzerland?

If your English version serves anyone who reads English, “en”. If it’s only for Switzerland, with prices in francs and local contact details, you can use “en-CH”.

Sources

Tools that help

Glossary terms

Other guides

Want to know when we open?

One email to confirm and one on the day we open. Nothing else.

First we ask you to confirm your email; after that we only write on the day we open. Unsubscribe in one click. How we handle your email.