hreflang Tag Generator

Turn a list of language and country versions into hreflang tags, with the codes checked against ISO 639-1 and ISO 3166-1.

How to use

What it checks and how it works

The output follows Google's documentation on localized versions: every version lists itself and all the others, alternate URLs are fully qualified, and the value is an ISO 639-1 language code with an optional ISO 3166-1 alpha-2 region, or x-default. Codes are checked against the iso-639-1 and i18n-iso-countries packages, and the tool fixes letter case (language lower-case, region upper-case) and replaces underscores with hyphens. A code that is not in those lists, such as es-419, is flagged because Google states it supports only ISO 639-1 languages and ISO 3166-1 alpha-2 regions. hreflang is a hint for matching users to versions; it does not move rankings between versions.

Which code do I use for Arabic?

ar for Arabic in general, or a language and country such as ar-EG for Egypt, ar-SA for Saudi Arabia and ar-AE for the UAE. Use a country code only when you have a version written for that country.

Do I need x-default?

It is optional. Google describes it as the fallback for users whose language you do not list, such as a language selector page.

Where do the tags go?

Use one of three equal methods: link tags in the head of every version, an HTTP Link header (for PDFs and other files) or xhtml:link entries in a sitemap. Pick one method and keep it consistent.

Sources

Related tools

Privacy

Runs in your browser; nothing is uploaded. The interactive tool needs JavaScript.