# Hreflang Implementation: Link Tags, HTTP Headers, Sitemaps, and x-default

> Implement hreflang with HTML link elements, HTTP Link headers, or XML sitemaps, including language-region codes, x-default, return links, and canonical alignment.

**Quick answer:** Hreflang tells search engines which language or regional variant of a URL to serve. Publish it with HTML link elements, HTTP Link headers, or XML sitemaps, using ISO language and region codes. Every page must reference itself and every other variant, include one x-default fallback when needed, stay indexable, and be canonical to itself with no redirects.

## Key takeaways

- Hreflang selects the right localized URL for a user; it is not a ranking boost, a redirect, or a geotargeting setting.
- Every variant must publish the complete cluster, including a self-reference and a link back from every other variant.
- Language-only codes address all speakers; add an ISO 3166-1 region only when the content genuinely differs by country.
- One x-default names the fallback for unmatched languages, and every annotated URL must be indexable and self-canonical.
- Verify the cluster from the outside: final 200 URLs, valid codes, reciprocal links, one canonical per page, and no mixed signals.

---

Hreflang looks like a one-line annotation and behaves like a contract between every localized version of a page. A search engine reads the annotations, checks that each URL acknowledges the others, confirms that every target is indexable and canonical to itself, then chooses the version to serve for a language or region. Break one clause and the engine may ignore the whole cluster, usually without an error message.

The markup is trivial; the graph is not. Every page must know every other page, every URL must resolve cleanly, and canonical signals must agree. This guide covers the delivery methods, code syntax, `x-default`, return links, canonical interaction, URL strategy, content parity, common mistakes, and a verification pass.

## What hreflang actually does and what it does not

An hreflang annotation declares that one URL is a language or regional alternative of another. The standard form is a `rel="alternate"` link with an `hreflang` attribute holding a language code and optionally a region: `hreflang="de-AT"`. The value describes the audience of the target page, not the language of the page carrying it.

Search engines use these declarations as hints when choosing which URL to show to a user searching in a particular language or region. Hreflang is not a ranking factor, does not transfer authority, and does not redirect. A German user can still land on the English page. Hreflang removes ambiguity: when several equivalents exist, it says which one is intended for which audience.

Hreflang is also not geotargeting. It maps language and regional variants of the same content; geotargeting tells a search engine which country a site serves. A country-code top-level domain is a geotargeting signal; `hreflang="de-DE"` on a `.com` page is not.

Nor is hreflang a translation strategy. It cannot make untranslated content rank, and it should not announce placeholders. The annotation is a claim of equivalence, and search engines verify that claim against the content.

## Three delivery methods: HTML link elements, HTTP Link headers, and XML sitemaps

Three delivery methods publish the same cluster. They carry identical semantics and can be combined, but different contents create conflicts, so choose one source of truth per site or template.

HTML link elements live in the head. They are the easiest to review and template, and the default for ordinary pages:

```html
<link rel="alternate" hreflang="en" href="https://www.example.com/en/guides/hreflang/">
<link rel="alternate" hreflang="de" href="https://www.example.com/de/guides/hreflang/">
<link rel="alternate" hreflang="fr" href="https://www.example.com/fr/guides/hreflang/">
<link rel="alternate" hreflang="x-default" href="https://www.example.com/guides/hreflang/">
<link rel="canonical" href="https://www.example.com/en/guides/hreflang/">
```

Every `href` is absolute, uses the final HTTPS host, and includes the full path. The English page lists itself as `en`, the other variants, the fallback, and its canonical. Relative URLs may resolve differently behind a proxy; absolute URLs remove the ambiguity.

HTTP `Link` headers carry the same relations without touching HTML. A response sends `Link: <https://www.example.com/de/guides/hreflang/>; rel="alternate"; hreflang="de"`, repeated per variant. Headers are the only response-level option for non-HTML resources such as PDFs, and they suit edge-managed stacks. The constraints are stricter: present on every variant, identical for every user and crawler, preserved through CDN rewriting. A CDN rule that strips unknown headers silently removes the cluster.

XML sitemaps use the XHTML namespace and repeat the full set inside every `<url>` entry:

```xml
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url>
    <loc>https://www.example.com/de/guides/hreflang/</loc>
    <xhtml:link rel="alternate" hreflang="en" href="https://www.example.com/en/guides/hreflang/"/>
    <xhtml:link rel="alternate" hreflang="de" href="https://www.example.com/de/guides/hreflang/"/>
    <xhtml:link rel="alternate" hreflang="fr" href="https://www.example.com/fr/guides/hreflang/"/>
    <xhtml:link rel="alternate" hreflang="x-default" href="https://www.example.com/guides/hreflang/"/>
  </url>
</urlset>
```

Sitemap annotations apply only to URLs in the sitemap; each entry still lists the complete set. Generate the sitemap from the same localization manifest as the pages.

| Method | Best suited to | Hard requirement | Typical failure |
| --- | --- | --- | --- |
| HTML link elements | HTML pages and template-driven sites | Full set in the head of every variant | Template renders only the other languages |
| HTTP Link headers | PDFs, non-HTML assets, edge-managed stacks | Identical header on every response | CDN strips it or caches it inconsistently |
| XML sitemap | Large sites, many locales, slow templates | Complete `xhtml:link` set per `<url>` | Only some variants are listed |

## Language-only versus language-region codes

An hreflang value follows `language` or `language-region`. The language subtag is an ISO 639-1 code such as `en`, `de`, `fr`, `ja`, or `zh`; the optional region is an ISO 3166-1 Alpha-2 code such as `US`, `GB`, `DE`, or `TW`. Matching is case-insensitive; the convention is lowercase language and uppercase region.

A language-only code targets every speaker of that language. `de` is right when one German page serves Germany, Austria, and Switzerland. A region narrows the audience: `de-AT` is German for Austria, `de-CH` for Switzerland. Add the region only when pricing, shipping, legal terms, spelling, or catalog genuinely differ. Identical pages for three countries add noise and risk overlapping clusters.

Overlap is subtle. A cluster with `de`, `de-DE`, and `de-AT` asks the engine to choose between a general page and two specific ones. That can be legitimate, but each URL needs exactly one value, and the set must be deliberate. The common accident is annotating one URL twice, as `en` and `en-US`, or publishing `en-GB` for all English content and leaving American users to the fallback.

Region-only values are invalid: `US`, `GB`, and `DE` must be paired with a language. Codes that look plausible but are not standard are equally invalid. `en-UK` uses the wrong country code because the United Kingdom is `GB`; `de-EU` invents a region because the EU is not an ISO 3166-1 country; `en_US` uses an underscore where the syntax requires a hyphen; `es-419` is a UN M.49 code outside the documented ISO 3166-1 set, so use `es` or a specific country.

Script subtags are valid BCP 47 and useful for Chinese: `zh-Hans` for simplified, `zh-Hant` for traditional, optionally with a region. Pick one convention; mixing `zh-CN` and `zh-Hans` splits the cluster.

| Value | Meaning | Use it when |
| --- | --- | --- |
| `de` | German, any region | one German page serves all German-speaking markets |
| `de-AT` | German for Austria | Austrian pricing, shipping, or legal content differs |
| `en-GB` | English for the United Kingdom | British spelling or UK-specific offers are distinct |
| `zh-Hans` | Simplified Chinese | script, not country, is the meaningful difference |
| `x-default` | fallback for unmatched users | a real selector or global page exists |

## x-default: the fallback for unmatched languages

`x-default` marks the page to serve when no annotation matches the user's language or region. It is optional, but when a site has a global landing page, a language selector, or an English catch-all, `x-default` is how to say so.

The fallback must be a real page: `200`, indexable, useful, and part of the same return-link graph. Pointing it at a redirect, a domain that redirects by IP, or an interstitial crawlers cannot render defeats the purpose. It is not a dumping ground for untranslated content; it is the page a Norwegian user should see when only English, German, and French exist.

Use exactly one `x-default` per cluster and include it in every variant's set, including the fallback page when that page carries annotations. Never combine it with another value: `hreflang="x-default en"` is invalid. If the fallback is the English page, it can appear twice, as `en` and `x-default`, pointing at the same URL; that is valid and common.

## Return links and self-referencing entries

Hreflang is bidirectional. If the English page declares the German page as its `de` variant, the German page must declare the English page as its `en` variant. Search engines treat a one-way declaration as unconfirmed and may ignore it. The rule prevents a page from claiming a relationship the other page does not recognize.

Self-reference is the other half. Every page must include an annotation pointing to itself with its own value. A template that renders only the other languages is the most common bug: the French page lists English and German but not French, and the cluster loses its anchor. For N languages, every page carries N link elements, plus `x-default` if used.

The graph must be complete, not merely reciprocal in pairs. If English lists German and French, but German lists English and not French, the German-French edge is broken. Sitemap delivery repeats the rule: each `<url>` entry contains the complete set, never a subset.

Exact matching matters. A return href must resolve to the same URL after normalization: same scheme, host, path, and trailing slash. A link to `http://example.com/de` that redirects to `https://www.example.com/de/` points at a redirect, not the final page. Normalize once at generation time and use the normalized absolute URL everywhere.

## Canonical and hreflang: two signals that must agree

Canonicalization and hreflang answer different questions. A canonical says these URLs are the same page and asks for one to be indexed. Hreflang says these URLs are different language or regional versions and asks for the appropriate one to be served. They coexist only when every hreflang target is canonical to itself.

The safe rule: every URL in a cluster carries a self-referencing canonical whose href is identical to its hreflang href. If the German page canonicalizes to the English page, it declares itself a duplicate, and the `de` annotation contradicts that. Search engines resolve the conflict by trusting the canonical and dropping the German URL from the cluster.

The reverse mistake is collapsing regional variants. An `en-GB` page canonicalizing to `en-US` tells search engines there is one English page. That is correct if the content is identical and the regional version has no value; it is wrong if British users should see a distinct page. Choose one mechanism per relationship: duplicates get a canonical, variants get hreflang. Applying both produces silence, not compromise.

Use absolute URLs and generate canonical, hreflang, sitemap `loc`, and social metadata from one builder so they cannot drift.

## URL strategies: ccTLD, subdomain, subdirectory, and parameters

URL structure determines infrastructure and authority; hreflang connects whatever structure you choose. A ccTLD such as `example.de` is the strongest geotargeting signal and a clean local identity, but it splits authority, needs separate certificates and Search Console properties, and multiplies cost. Hreflang is still required to connect the ccTLDs and the global site.

Subdomains such as `de.example.com` centralize infrastructure while keeping hosts separate. They are easier to operate than ccTLDs and allow per-market configuration, but inherit less geotargeting strength. Subdirectories such as `example.com/de/` are simplest: one host, one certificate, one authority profile, and a deployment path most frameworks support. They carry no geotargeting signal, which is acceptable when hreflang and content do the language work.

Query parameters such as `?lang=de` are supported but fragile: duplicate URLs, caching and analytics complications, and easy loss during redirects. If unavoidable, keep them stable, avoid cookies for locale, and include the parameter in canonical and hreflang values in the same order. Never choose a locale by IP or `Accept-Language` and redirect before serving; crawlers see only one version.

Keep protocol and host consistent. Point annotations at `https`, at the canonical `www` or apex host, and at the final path. Mixed `http`/`https` or `www`/non-`www` URLs create clusters that look correct in a spreadsheet and fail in a crawl.

## Content parity, noindex, and honest clusters

Hreflang asserts equivalence. Each target should be a genuine translation or regional adaptation of the same intent, with translated title, description, navigation, and body. A page that swaps a currency symbol but leaves the article in English is not a German variant; a machine-translated stub with untranslated interface text is not a French variant. Search engines can compare content and may disregard annotations that do not hold up.

If a translation does not exist, omit that locale. Do not annotate a placeholder, a coming-soon page, or a redirect to English. A smaller valid cluster outperforms a larger broken one and can grow when content ships. The same rule applies to `x-default`: a real experience, not a promise.

Indexability is hard. A `noindex` page cannot be served, so annotating it is wasted and can invalidate the other pages' expectations. Remove `noindex` before adding a URL, or leave it out. Do not pair `noindex` with a canonical as belt and braces; the directives conflict and search engines pick one.

Regional differences are legitimate: prices, availability, legal notices, even product names. What must not differ is the reason to visit. A German checkout flow and an English marketing article are not equivalents, and the annotation will eventually be ignored.

## Common mistakes that silently disable hreflang

Most hreflang failures are not syntax errors. They are graph errors, status errors, and conflicts with other signals. Check these first:

| Mistake | Why it fails | Fix |
| --- | --- | --- |
| Missing return links | One-way claims are unconfirmed | Publish the full set on every variant |
| Missing self-reference | The cluster has no anchor on that page | Add the page's own value |
| Invalid region code | `en-UK`, `de-EU`, and region-only values are invalid | Use `en-GB`, `de`, or no region |
| hreflang points at a redirect | The signal stops before the final page | Annotate the final `200` URL |
| Canonical points elsewhere | The page is declared a duplicate and dropped | Self-canonical or remove it |
| Conflicting canonical targets | The cluster splits along canonical lines | One canonical matching each href |
| `noindex` target | A non-indexable page cannot be served | Remove `noindex` or the annotation |
| Two values on one link | The attribute accepts one value | Split into separate link elements |
| hreflang used for geotargeting | It does not set country targeting | Use a ccTLD and local signals |
| HTML and header sets disagree | Conflicting sources are ignored | Keep one source of truth |

The thread is consistency. Hreflang fails when one page, template, or CDN rule disagrees with the rest. A generated cluster, where one data structure produces HTML, headers, sitemap entries, canonicals, and the language switcher, eliminates most of these before production.

## Verification checklist and production rollout

Verify from the outside against the deployed site, in the order a crawler travels: status codes, canonical tags, cluster graph, delivery method. Source inspection is not enough; CDNs, frameworks, and middleware rewrite heads.

| Check | How to verify | Pass criteria |
| --- | --- | --- |
| Status code | Request every variant | `200` with no `Location` header |
| Self-reference | Inspect each page head | The page lists its own absolute URL |
| Return links | Crawl all variants as a set | Every page lists every page, including itself |
| Canonical | Compare with the hreflang href | Self-referencing and string-identical |
| x-default | Request the fallback URL | `200`, indexable, present in every set |
| Indexability | Check robots meta and `X-Robots-Tag` | No `noindex` and no blocked path |
| Language codes | Validate against ISO 639-1 and ISO 3166-1 | No `en-UK`, region-only, or underscore |
| Sitemap set | Parse one `<url>` entry | Complete `xhtml:link` set including self |
| Header set | Inspect `Link` on each response | Same full set on every variant |
| Content parity | Read each target in its language | Translated title and body, equivalent intent |

Treat the cluster as code. Add a test that builds the graph from the localization manifest and fails on a wrong return link, self-reference, canonical, or status code, and re-run it after every locale launch or redirect change. Search Console reports what the engine concluded, not what your templates published. The [meta tag generator](/tools/meta-tag-generator) produces the canonical and page metadata that must match the cluster, the [URL parser](/tools/url-parser) checks that every host and path matches the manifest, and the [HTTP request workbench](/tools/http-request) verifies status codes and `Link` headers exactly as a crawler receives them.

Roll out in order: publish a final `200`, add the canonical, add the page to every variant's set, then add the sitemap entry or header. To remove a locale, take it out of every set first, then redirect or retire the URL. A cluster is only as strong as its least consistent member.

## Frequently asked questions

### Does hreflang improve rankings in the target language?

No. Hreflang is a hint for selecting the appropriate language or regional URL when several equivalents exist. It does not raise rankings, transfer authority, or substitute for translated content that satisfies the query.

### What happens when return links are missing?

A one-way annotation is unconfirmed. Search engines may ignore the declaration, so the page can keep appearing for the wrong audience or lose the localized alternative entirely. Every variant must list every other variant, including itself.

### Can I point hreflang at a URL with a different canonical?

No. Each hreflang target should be canonical to itself. If the target canonicalizes elsewhere, the page is declaring itself a duplicate and the annotation conflicts, so search engines may drop it from the cluster.

### Do I need hreflang for a single-language site?

Not for language selection alone. Hreflang becomes useful when the site serves regional variants, such as English for the United States and the United Kingdom, or when several languages share one domain and need to be connected.

### Is hreflang the same as geotargeting?

No. Hreflang maps language and regional variants of the same content. Geotargeting tells search engines which country a site serves, and the clearest signal is a country-code top-level domain, not an hreflang attribute.

## References

- [Google Search Central: Localized versions](https://developers.google.com/search/docs/specialty/international/localized-versions)
- [W3C: Language tags in HTML and XML](https://www.w3.org/International/articles/language-tags/)
- [Google Search Central: Canonicalization](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls)
- [Schema.org: WebPage](https://schema.org/WebPage)

---

- Canonical: https://www.jsonmind.com/guides/hreflang-implementation
- Locale: en
- Published: 2026-11-17
- Updated: 2026-11-17
- Tools: meta-tag-generator, url-parser, http-request