Guide
Marking language and region versions with hreflang
When the same content exists in several languages, or in one language for several countries, search engines must decide which version to show a searcher. The hreflang annotation tells them. It does not rank pages higher; it helps the right version appear for the right person and avoids having the versions treated as duplicates. The format is easy to get subtly wrong, and this generator writes it from a short list.
Entering your versions
Each line holds a code, a bar and the full address of that version, for example en-GB | https://shop.example/uk/. The first column is a language code such as en, optionally followed by a script and a region, as in zh-Hant, pt-BR or en-GB. The word x-default is also accepted. The tool checks each code against this pattern and each address for a full http or https form, and flags duplicate codes and other mistakes by line number. A bar, a tab, a comma or a space may separate the two columns.
Three ways to publish the same facts
Choose what to show. HTML link tags go in the head of every version and are the easiest for small sites. An HTTP Link header carries the same information for files that have no HTML head, such as PDFs. Sitemap entries put the alternates inside the XML sitemap, with an xhtml:link element for every version inside each url block, which suits large sites because pages stay lighter. The fourth option prints all three.
Why the set must be complete
Each page must list every version, including itself. If the English page points to the German one but the German page does not point back, search engines may ignore the pair. The output is therefore one block that you place on every page of the set, unchanged. That is why the tool asks you to enter the whole set once rather than one page at a time.
Country codes that trip people up
The language comes first, then the region. English for the United Kingdom is en-GB, never en-UK, because GB is the region code for the United Kingdom. The tool expects the usual writing, lower-case language and upper-case region, and rejects en-gb or a region alone such as GB. It also warns when no x-default line is present.
A worked example
The sample has five lines: en for the home page, en-GB for /uk/, fr-FR for /fr/, de for /de/ and x-default pointing to the home page. The tool reports 5 versions and prints five link tags, such as <link rel="alternate" hreflang="fr-FR" href="https://shop.example/fr/" />. In sitemap form it prints a url block for each of the four distinct pages, each containing all five xhtml:link lines, and a note says to add the xhtml namespace to the urlset element.
Limits
The tool formats annotations. It does not fetch your pages, so it cannot confirm that each version exists, that the return links are in place or that the language of the content matches the code. Search engines may also ignore hreflang when a page is blocked, redirected or marked as a duplicate of another. After publishing, test a sample of pages with a crawler or Search Console.
Related tools
- Canonical Tag Generator sets the preferred address that each language page should point to for itself.
- XML Sitemap Generator builds the base file into which the alternate entries go.
- robots.txt Generator and Tester makes sure no language folder is blocked by mistake.
- Schema Markup Generator adds the other tags that belong in the head of each version.
Checked against the current version of the Hreflang Tag Generator on .

