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, soen-UKis ignored, as areEUandUN. Google also listses-419(Latin American Spanish) among unsupported values, although it is valid BCP 47. - Country codes used as languages. Japanese is
ja, notjp; Czech iscs, notcz; Swedish issv(seis Northern Sami). - Underscores.
pt_BRis 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.