Setting up hreflang for multilingual sites
hreflang tells Google which version of a page is intended for which language and region. Without proper hreflang, search engines show incorrect language versions to users — Russian version ranks in Germany, English ranks in Russia.
Tag syntax
<!-- On each language version of the page, add ALL alternatives -->
<link rel="alternate" hreflang="ru" href="https://example.ru/products/laptop">
<link rel="alternate" hreflang="en" href="https://example.com/products/laptop">
<link rel="alternate" hreflang="uk" href="https://example.ua/products/laptop">
<link rel="alternate" hreflang="de" href="https://example.de/products/laptop">
<link rel="alternate" hreflang="x-default" href="https://example.com/products/laptop">
x-default — default version for users whose language doesn't match any specified, or for language selection page.
Regional specificity
When you need to separate by country, not just language:
<link rel="alternate" hreflang="ru-RU" href="https://example.ru/products/laptop">
<link rel="alternate" hreflang="ru-UA" href="https://example.ua/ru/products/laptop">
<link rel="alternate" hreflang="ru-KZ" href="https://example.kz/products/laptop">
<link rel="alternate" hreflang="en-US" href="https://example.com/products/laptop">
<link rel="alternate" hreflang="en-GB" href="https://example.co.uk/products/laptop">
Implementation in Laravel
// config/locales.php
return [
'ru' => ['hreflang' => 'ru', 'domain' => 'example.ru'],
'en' => ['hreflang' => 'en', 'domain' => 'example.com'],
'uk' => ['hreflang' => 'uk', 'domain' => 'example.ua'],
'de' => ['hreflang' => 'de', 'domain' => 'example.de'],
];
// In controller
public function show(string $slug): View
{
$page = Page::where('slug->ru', $slug)
->orWhere('slug->en', $slug)
->firstOrFail();
$hreflangs = $this->buildHreflangs($page);
return view('page', compact('page', 'hreflangs'));
}
protected function buildHreflangs(Page $page): array
{
$locales = config('locales');
$hreflangs = [];
foreach ($locales as $locale => $config) {
$slug = $page->getTranslation('slug', $locale);
if ($slug) {
$hreflangs[$config['hreflang']] = 'https://' . $config['domain'] . '/' . $slug;
}
}
$hreflangs['x-default'] = $hreflangs['en'] ?? reset($hreflangs);
return $hreflangs;
}
@foreach ($hreflangs as $lang => $url)
<link rel="alternate" hreflang="{{ $lang }}" href="{{ $url }}">
@endforeach
Hreflang in XML Sitemap
Alternative to tags in <head> — specify in sitemap. More convenient for large sites:
<url>
<loc>https://example.ru/products/laptop</loc>
<xhtml:link rel="alternate" hreflang="ru" href="https://example.ru/products/laptop"/>
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/products/laptop"/>
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/products/laptop"/>
</url>
Common mistakes
- One-directional specification — if page A links to B as alternative, page B must link back to A
- Non-existent URLs — hreflang with 404 or redirect is ignored
- Different content — same content with different language hreflang is perceived as duplicates
- Wrong language code — only ISO 639-1 for language and ISO 3166-1 Alpha-2 for country
Verification
Google Search Console → Coverage → check hreflang errors. hreflang Tags Testing Tool (Merkle SEO) lets you verify tag correctness on a page.
Setup time: 1–2 days for multilingual site with multiple domains.







