hreflang tag generator
Add each language or regional version of a page and its URL. The generator writes the <link rel="alternate" hreflang> tags and checks for the mistakes that make Google ignore hreflang: invalid codes, duplicates, relative URLs and a missing x-default.
- Put this same set of tags on every URL listed, including each page itself. Every version must link back, or Google ignores the pair.
<link rel="alternate" hreflang="en-US" href="https://example.com/">
<link rel="alternate" hreflang="en-GB" href="https://example.com/uk/">
<link rel="alternate" hreflang="de" href="https://example.com/de/">
<link rel="alternate" hreflang="x-default" href="https://example.com/">The rules Google applies
- Codes: a language (ISO 639-1, like
de) optionally followed by a region (ISO 3166-1, likede-AT). A region on its own is invalid, and the UK isGB, soen-UKis wrong. - Return links: if page A lists page B, page B must list page A. Missing return links are the most common reason hreflang does nothing.
- Self-reference: each page lists itself as well as the others.
- Absolute URLs, and each URL should be the canonical, indexable version.
- x-default names the page for everyone else, often a language picker or the main site.
Where to put the tags
Put the same full set in the <head> of every version. Alternatives are HTTP headers (useful for PDFs) or the XML sitemap, which is easier to maintain on large sites. Use one method, not a mix. On WordPress, multilingual plugins such as WPML or Polylang generate hreflang for you, so check what they already print before adding your own. The hreflang setup guide covers this.
Common questions
Do I need hreflang for a single-language site?
No. hreflang only matters when you have the same content in more than one language or for more than one region.
Is hreflang a ranking signal?
No. It helps Google show the right language or regional version to each searcher. It does not make any version rank higher.
Should x-default point to my English page?
Only if English is the version you want everyone else to see. Many sites point x-default at a language selector or the main international site instead.