Hreflang tag generator
Write the tags that connect your pages in different languages.
If the same page exists in more than one language, search engines have to be told the versions belong together. Hreflang does that, and it is easy to get wrong. The codes come from three separate standards. Every version has to point at every other version including itself, and a set with one missing return link is ignored in full rather than in part. Enter an address and a language code on each row, or enter one address and let the tool build the rest. Codes are read back in plain words as you type, so a mistake surfaces before it reaches a live page. The output is a block for the head of the page, an HTTP header for files that are not HTML, or entries for your sitemap.
Every version lists every version
A page that names an alternate has to be named back by it, or the annotation is ignored. That rule exists so that nobody on another site can name your page as an alternate version of theirs without your agreement. The set is identical on every address, so one block covers all of them.
The codes come from three standards
Language is ISO 639-1. Region is ISO 3166-1 alpha-2, and script, where a language needs one, is ISO 15924. A single code can carry all three, as in zh-Hans-US. Each part is checked on its own, which catches the codes that parse but mean something other than you intended. The clearest example is be, which is Belarusian rather than Belgium.
Pick one method and stay with it
Tags in the head of the page, a Link header in the response, or entries in the sitemap. Google treats them as equivalent, so using more than one adds maintenance without adding meaning. Tags suit most sites. The header exists for files that are not HTML, such as PDFs, and the sitemap keeps the markup out of every template.
The fallback points at a page you already have
x-default covers visitors whose language matches nothing else in the set. It points at one of the addresses you have already listed, usually a language selector or the main version. Tick Fallback on that row and the tag is written for you.
Every part of every code, and the set as a whole.
- Language from ISO 639-1
- Region from ISO 3166-1 alpha-2
- Script from ISO 15924
- Duplicate codes and addresses
- More than one fallback
- Mixed http and https
- Tags for the head
- Link header for other files
- Sitemap entries
- Subdirectory, subdomain or country domain
- Query string addresses
- One address expanded to every language