What hreflang does
hreflang tells search engines that several URLs are the same page in different languages or for different regions, and which is which. When a user in Germany searches, Google can then show your German page instead of the English one. It doesn’t translate anything and doesn’t boost rankings. It picks the right version among pages you already have.
How the codes work
Each value is a language code, optionally followed by a region: de, en-GB, es-MX.
- Language: ISO 639-1, two letters. Japanese is
ja, notjp; Danish isda, notdk; Swedish issv, notse. - Region: ISO 3166-1 alpha-2, two letters. The United Kingdom is
GB, notUK. - A region can’t stand alone.
uson its own isn’t valid; useen-US. - x-default is the fallback for users who match none of your versions.
Codes are case-insensitive. We write the language in lowercase and the region in uppercase, the common convention. The generator checks every code against the full ISO lists and flags the usual mix-ups.
The rules that break most setups
- Reciprocal links. If the English page lists the German page, the German page must list the English page back. Missing return links are a common hreflang error, and Google may ignore annotations that aren’t confirmed.
- Self-reference. Every page lists itself as well as the others. Paste the same block on every version.
- Full URLs. Use absolute URLs with https://. Relative paths aren’t allowed.
- Indexable targets. Every URL should return 200, be indexable and have a self-referencing canonical. Don’t point hreflang at redirects or noindexed pages.
Three ways to add it
Choose the output format above. HTML goes in the <head> of every version. XML sitemap writes one <url> entry per version, each listing all alternates, with the xhtml namespace declared. HTTP header is for files without HTML, like PDFs. Use one method per set of pages. Check which hreflang tags a live page already has with the meta tag checker.