Hreflang tag generator

List every language version of a page. The generator checks each code and URL against the rules search engines apply, then gives you the annotations as HTML tags, an HTTP header, a sitemap block and a Laravel Blade loop. Everything runs in your browser.

x-default

All codes and URLs are valid. Remember: every URL listed below must carry this same set of annotations.


                

The rules the generator checks

Google's documentation on localized versions accepts language codes from ISO 639-1, optionally followed by a region from ISO 3166-1 alpha-2, and lets you name the script with an ISO 15924 code such as zh-Hant. The value is case-insensitive, so the generator only normalizes it to the conventional en-GB form. What it flags:

  • Region on its own. hreflang="US" is not valid; the language always comes first (en-US).
  • Codes that are not ISO 3166-1. The United Kingdom is GB, so en-UK is ignored, as are EU and UN. Google also lists es-419 (Latin American Spanish) among unsupported values, although it is valid BCP 47.
  • Country codes used as languages. Japanese is ja, not jp; Czech is cs, not cz; Swedish is sv (se is Northern Sami).
  • Underscores. pt_BR is a fine Laravel folder name, but language tags use hyphens: pt-BR.
  • Relative URLs and duplicates. Alternate URLs must be fully qualified, with https://, and each code may appear only once.

Self-reference and return links

Hreflang is a set, not a pointer. Each language version must list itself and every other version, and if page A names page B, page B has to name page A back; when two pages do not point to each other, the annotations are ignored. In practice that means the exact block the generator prints goes on every URL in it. That is also why the sitemap output repeats the full list inside each <url> entry.

x-default is the page for visitors whose language matches none of the others, typically a language picker or your main version. It takes a URL but no language code.

A worked example

The prefilled rows describe a pricing page in four versions: generic English, British English, German and Mexican Spanish, plus an x-default for everyone else. A visitor searching in English from Ireland matches no regional version, so search engines can show the generic en page; someone in the UK gets en-GB. That is why a plain language code alongside your regional ones is worth having: it catches every country you did not list. Change en-GB to en-UK or delete the protocol from a URL to see the checks fire, then copy the share link to send the exact set to a colleague; the rows are stored in the link itself, not on our server.

HTML, HTTP header or sitemap?

Google treats the three methods the same and says using more than one brings no benefit, so pick the one that is easiest to keep correct. Link tags belong inside <head>; the HTTP Link header is the option for PDFs and other non-HTML files; the sitemap keeps the markup out of your pages entirely and needs the xmlns:xhtml namespace on <urlset>.

Doing it in Laravel

Hand-written tags drift as soon as you add a locale. In a Laravel app with localized routes, generate them in one Blade partial from a list of locales, as the Blade tab shows. Note the two spellings: Laravel's lang folders conventionally use underscores (lang/pt_BR), while the hreflang value and the lang attribute use hyphens. The locale code lookup shows both for any code, and the BCP 47 and ISO 639-1 glossary entries explain where the codes come from. For URL structure, sitemaps and why cookie-based locale switching is invisible to crawlers, read multilingual SEO in Laravel.

Frequently asked questions

Does a page need an hreflang tag pointing to itself?

Yes. Each language version must list itself as well as every other version. In practice the same block of tags goes on every URL in the set, which is why the generator outputs one block for all of them.

Why is en-UK wrong?

Region codes come from ISO 3166-1 alpha-2, where the United Kingdom is GB. UK is not an assigned code, so Google ignores an hreflang of en-UK. Use en-GB.

What is x-default for?

x-default names the page to show when none of the listed languages matches the visitor, usually a language picker or your main version. It takes only a URL, no language code, and like the other values it belongs on every version of the page.

Should I use HTML tags, HTTP headers or the sitemap?

Any one of them. Google treats the three methods as equivalent and says combining them brings no benefit. Link tags in the head are simplest for HTML pages, the Link header works for files such as PDFs, and the sitemap keeps the annotations out of your templates.

Are hreflang codes case-sensitive?

No. Google accepts upper and lower case, so en-gb and en-GB mean the same thing. The generator writes the conventional form, lowercase language and uppercase region, so the output is consistent.

Useful? Link to it

The tool is free and stays free. Paste this into a README, a wiki page or a forum answer.

<a href="https://langsyncer.com/tools/hreflang-generator">Hreflang Tag Generator</a> by LangSyncer

Translate the pages your hreflang points to

Hreflang only helps if every language version exists and stays current. LangSyncer translates your Laravel lang files with AI, tracks what is missing per language and publishes changes without a deploy.

We'd like to use analytics and marketing cookies to understand how the site is used. They stay off unless you accept them. Cookie Policy