hreflang tags with invalid codes, missing return links or broken alternates
hreflang tags tell Google which language or regional version of a page to show each searcher. On every version, list all the versions, the page itself included, with full https addresses and valid codes: a language such as en, optionally with a country such as en-GB, plus x-default for everyone else. Each version must link back, and each address must be a live, indexable, canonical page.
Why it matters
When the same page exists in several languages, or for several countries, hreflang annotations tell Google about each version so its results can link to the right one. Google reads them from <link rel="alternate" hreflang="..."> elements in the page's <head>, from the Link HTTP header or from your XML sitemap, and says the three methods are equivalent. Pick one: using all three brings no benefit in Search and is much harder to manage.
The annotations work in pairs. Each language version must list itself as well as all the other versions, and if two pages do not both point to each other, Google ignores the tags between them. Google still uses the pairs that do point to each other, so a set with gaps is not worthless, but every missing return link is a version Google may not connect.
The codes must be ones Google supports: an ISO 639-1 language code, optionally followed by a script, such as zh-Hans, and an ISO 3166-1 alpha-2 region code. A region on its own is not valid, UK, EU and UN have no effect as regions (the code for the United Kingdom is GB), and codes from other standards, such as es-419 for Latin American Spanish, are not supported. Case does not matter. Google's examples join the parts with a hyphen, and SERPCompass also flags an underscore, as in en_GB.
x-default names the page for searchers whose language matches none of your versions. Google recommends it for that fallback page and says it was designed for language selector pages. It is not required, which is why SERPCompass reports a missing one as a notice.
Each alternate should be the address Google will show. Google does not use the content of a URL that answers a 4xx code, cannot crawl a URL robots.txt blocks, so never sees the return link on it, drops a noindex page from its results entirely, and shows the target of a permanent redirect rather than the URL that redirects. Its canonical guide also asks pages with hreflang to name a canonical in the same language. SERPCompass flags alternates that fail any of these.
hreflang does not tell Google what language a page is in: Google says it uses neither hreflang nor the lang attribute for that, but the page's visible content. SERPCompass rates invalid codes, missing return links, broken or non-canonical alternates and conflicting annotations as warnings, and a missing self-reference or x-default as notices.
The audit findings this guide fixes: Invalid hreflang codes; hreflang without return links; hreflang set without a self-reference; hreflang set without x-default; hreflang points to a broken or redirecting URL; hreflang points to a noindex or canonicalised page; Conflicting hreflang annotations.
Find every page with this problem
Run the free scan on your domain. It reads the hreflang annotations of every page it crawls, from the HTML, the Link header and your sitemap, and judges the pages that stand for themselves: not noindex, and not canonicalised to another URL. It flags codes that are not a language with an optional script and country, or x-default, and says what to use instead, such as en-GB for en-UK; sets in which a page does not list itself or has no x-default; a code that names two different URLs; and alternates that answer an error, redirect, could not be fetched, are blocked for Googlebot by robots.txt, are noindex or name another URL as their canonical. For every alternate it crawled that is live and canonical, it checks for an annotation back to the page. Alternates on other sites, or beyond the scan's page budget, are not judged. The scan shows your most urgent findings with the number of pages each affects; the Gap Report and a SERPCompass workspace list each page with the annotations at fault.
How to fix it on your platform
WordPress with WPML
- WPML inserts
<link rel="alternate" hreflang>tags that point every page to its translations. The setting is Display alternative languages in the HEAD section, in the SEO Options card under WPML > Settings > URLs and SEO, and it is on by default. - With the WPML SEO add-on and the XML sitemap of Yoast SEO or Rank Math, WPML SEO adds the tags to the sitemap and turns the HEAD option off, so the two never both carry them.
WordPress with Polylang
- Polylang adds hreflang attributes to translated pages automatically.
- It adds x-default only on the home page, so SERPCompass reports your other pages as having no x-default. That is a notice: Google recommends x-default but does not require it. A developer can change the values with Polylang's
pll_rel_hreflang_attributesfilter.
Shopify
- With markets and languages set up, Shopify creates hreflang tags for every international domain or subfolder, updates them when you change market domains or languages, and adds an x-default tag that points at your primary domain.
- Keep them on: from your Shopify admin, go to Online Store > Preferences. In the Social sharing image and SEO section, Automatic hreflang tags should be on. Shopify warns that turning it off can hurt your store's SEO.
- Turn it off only if your theme adds its own tags, built from Liquid's
localizationobject rather than hard-coded domains or handles. Linking versions of a page across separate Shopify stores is one case Shopify Markets cannot do for you.
Sources: International SEO for markets (Shopify Help Center); Using hreflang tags to direct your customers to their region-specific URL (Shopify Help Center); Use hreflang tags in your theme (Shopify.dev).
Wix
- Wix Multilingual adds hreflang and x-default tags to the code of your multilingual pages by default.
- Keep every language version indexable: in the editor, switch to the language with the Switch languages drop-down, open Pages & Menu, click More Actions next to the page, choose SEO basics and make sure Let search engines index this page is on. Then publish. A version hidden from search engines is an alternate Google will not show.
Source: Wix Multilingual: optimizing SEO settings for multilingual sites (Wix Help Center).
Squarespace
- Squarespace's multilingual route is its Weglot integration, on version 7.1: open the Site Languages panel and, under Multilingual by Weglot, click Connect, then Allow.
- Set up a language subdomain for each language: Squarespace says language subdomains add hreflang tags automatically.
- For a multilingual site built by hand, with separate pages for each language, Squarespace's help documents no hreflang tags and says SEO strategy is outside the scope of its support.
Sources: Creating a multilingual site with Weglot (Squarespace Help Center); Manually creating a multilingual site (Squarespace Help Center).
Webflow
- With Webflow Localize, each page lists its localized versions in its
<head>, and the auto-generated sitemap carries hreflang tags for every static and dynamic page. Webflow updates both when you publish. - To change how the tags are made, open the Localize panel > SEO: switch automatic generation on or off, and choose the published (canonical) URL or a custom base URL.
- If you use a custom sitemap, add the hreflang tags for each page yourself. Only locales with publishing enabled appear in the auto-generated sitemap.
Source: Localized SEO and locale routing (Webflow Help Center).
Plain HTML
- In the
<head>of each version, add a<link rel="alternate" hreflang="..." href="...">for every version, this page included, and one withhreflang="x-default"for the fallback page, such as a language selector. - Use full addresses with
https://, never/fr/or//example.com/fr/. - Write each code as a language, optionally a hyphen and a country:
en,en-GB,pt-BR,zh-Hans. Never a country on its own, and neverUKorEUas the country. - For a PDF or another file with no
<head>, send the same list in aLinkHTTP header. Or list the versions in your sitemap: each<url>gets an<xhtml:link>for every version, itself included, withxmlns:xhtml="http://www.w3.org/1999/xhtml"declared. - Use one method. If you use more than one, make each code name the same URL in all of them.
- Point every alternate at the final address of the version: one that answers 200, is not blocked by robots.txt, has no
noindexand names itself as canonical.
Sources: Tell Google about localized versions of your page (Google Search Central); How to specify a canonical URL with rel="canonical" and other methods (Google Search Central).
Examples
-
Good
<!-- on https://www.example.com/en/ --> <link rel="alternate" hreflang="en" href="https://www.example.com/en/"> <link rel="alternate" hreflang="de" href="https://www.example.com/de/"> <link rel="alternate" hreflang="de-CH" href="https://www.example.com/de-ch/"> <link rel="alternate" hreflang="x-default" href="https://www.example.com/">The same four lines go on the German and Swiss German pages, so every version lists itself and links back to the others.
-
Bad
<link rel="alternate" hreflang="en-UK" href="https://www.example.com/uk/">UKis not a country code, so Google ignores it: useen-GB. -
Bad
<link rel="alternate" hreflang="es-419" href="https://www.example.com/latam/">A UN region number. Google supports only two-letter country codes: use
esalone, or one code per country such ases-MX. -
Bad
<link rel="alternate" hreflang="fr" href="/fr/">Not a full address: Google asks for the scheme and host too.
-
Bad
HTML: hreflang="fr" -> https://www.example.com/fr/ Sitemap: hreflang="fr" -> https://fr.example.com/One code, two URLs for the same page: SERPCompass reports a conflict.
-
Good
<url> <loc>https://www.example.com/en/</loc> <xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/en/"/> <xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/de/"/> <xhtml:link rel="alternate" hreflang="x-default" href="https://www.example.com/"/> </url>In a sitemap, each
<url>lists every version, itself included. The/de/entry gets the same three links. -
Good
Link: <https://www.example.com/guide.pdf>; rel="alternate"; hreflang="en", <https://www.example.com/de/guide.pdf>; rel="alternate"; hreflang="de"For a PDF, the annotations travel in the HTTP header.
Common mistakes
- Adding hreflang to one version only, so the others never link back.
- Leaving the page itself out of its own list.
- Writing
en-UK,jp(Japan's country code; Japanese isja) or a country code on its own. - Pointing alternates at addresses that redirect, such as an old
http://address, instead of the final URL. - Setting a translated page to
noindex, or giving every language version a canonical that points at the English page. Google asks for a canonical in the same language. - Redirecting visitors to a language version by their IP address or browser language. Google asks you to avoid automatic redirects between language versions and to link to the other versions so people can choose.
- Annotating the same pages in the HTML and the sitemap with different URLs.
Questions and answers
Do I need hreflang tags if my site has only one language?
No. hreflang connects versions of the same page in different languages or for different regions. A site in one language for everyone has nothing to connect, and SERPCompass reports nothing about hreflang on pages without annotations.
Is x-default required?
No. Google recommends x-default to name the fallback page for searchers whose language matches none of your versions, and says it was designed for language selector pages. SERPCompass reports a missing x-default as a notice. Shopify and Wix add one for you; Polylang adds it on the home page only.
What happens if return links are missing?
Google ignores the annotations between two pages that do not both point to each other. It still uses the pairs that do, so add the missing return links rather than removing the set. SERPCompass names, for each page, the alternates that do not link back to it.
Does hreflang tell Google what language my page is in?
No. Google says it uses neither hreflang nor the lang attribute to detect a page's language: it uses the visible content. hreflang tells Google which other versions of a page exist, so its results can link to the right one for each searcher.
Should hreflang URLs be the canonical URLs?
Yes. Point each alternate at the canonical address of that version, a page that answers 200 and can be indexed. Google's canonical guide asks pages with hreflang to name a canonical in the same language. An alternate that redirects, is noindex or names another URL as its canonical is a version Google will not show.
More guides
- Canonical tags that are missing, conflicting or pointing at the wrong URL
- XML sitemaps that are missing, unreadable or list the wrong pages
- Redirect chains, loops and other redirect problems
- Pages blocked from Google by noindex or robots.txt
- All guides
- Free tools: checks for robots.txt and llms.txt that need no account.
Sources
- Tell Google about localized versions of your page (Google Search Central)
- Managing multi-regional and multilingual sites (Google Search Central)
- How to specify a canonical URL with rel="canonical" and other methods (Google Search Central)
- How HTTP status codes, and network and DNS errors affect Google Search (Google Search Central)
- Redirects and Google Search (Google Search Central)
- Block Search indexing with noindex (Google Search Central)
- Introduction to robots.txt (Google Search Central)
- International SEO for markets (Shopify Help Center)
- Using hreflang tags to direct your customers to their region-specific URL (Shopify Help Center)
- Use hreflang tags in your theme (Shopify.dev)
- Wix Multilingual: optimizing SEO settings for multilingual sites (Wix Help Center)
- Creating a multilingual site with Weglot (Squarespace Help Center)
- Manually creating a multilingual site (Squarespace Help Center)
- Localized SEO and locale routing (Webflow Help Center)
- Customize URLs, slugs, and SEO in WPML (WPML)
- Hreflang tag attributes and Polylang (Polylang)
Start with a free scan of your site.
Two to five minutes, no account. You get your three most urgent findings, and the exact count of everything else.