Hreflang tag generator
List the language versions of a page: the tool checks the language and region codes, then generates the tag block for the head and the XML sitemap version. Everything runs in your browser.
Enter at least two versions to generate the code.
What hreflang tags do
Hreflang tags tell Google that several pages are the same content in different languages or for different countries. Google then shows each searcher the version that matches their language and region: the US page in the United States, the UK page in Britain, the French page in France. Without them, the versions can compete with each other, or the wrong one can rank.
The three golden rules of hreflang
One, every page must list all the versions, itself included: the block generated here goes as it is into the head of each of the listed URLs. Two, annotations must be reciprocal: if the English page points to the French page, the French page must point back to the English page, otherwise Google ignores the annotation. Three, the URLs must be absolute, canonical and indexable.
Language and region codes, done right
The format is an ISO 639-1 language (en, fr, de), optionally followed by an ISO 3166-1 region (en-US, en-GB, fr-BE). A region on its own does not exist: "be" means Belarusian, not Belgium, and "uk" means Ukrainian, not the United Kingdom, which is "en-GB". The x-default code marks the version served by default to searchers who match none of the listed languages, often the international homepage or a language selector.
HTML tags or sitemap: where to declare them
Both methods work equally well for Google, but pick one and stick to it. Tags in the head are easier to add on a CMS; declaring them in the XML sitemap keeps each page lighter when the site has many versions.