Language Targeting
Detecting the user‘s language and showing the appropriate site version to improve UX and international SEO.
In brief
Language targeting is a set of methods that allow a site to detect a visitor's preferred language (via Accept-Language header, geolocation, or explicit choice) and serve content in that language. Proper implementation improves UX without harming SEO.
Methods to detect user language
- Accept-Language header – browser language setting (most reliable).
- IP geolocation – country of the user.
- Language switcher – explicit user choice (most accurate).
- Cookie / localStorage – persistent choice across sessions.
Example Accept-Language: `Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7`. Here `ru` has highest priority after the exact `ru-RU`.
Implementation example (JavaScript)
JAVASCRIPT
const userLang = navigator.language || navigator.userLanguage;
const lang = userLang.split('-')[0];
if (!localStorage.getItem('language-selected')) {
if (lang === 'ru' && !window.location.pathname.startsWith('/ru/')) {
window.location.href = '/ru/';
}
}SEO‑safe language targeting implementation
- Do not force redirect – give the user a choice (banner or button).
- Store the choice – use cookies/localStorage to avoid repeated redirects.
- Always show a language switcher – in the header or footer.
- Use 302 redirects for auto‑detection (temporary).
- Add Vary: Accept-Language – for correct caching.
- All language versions must be accessible to Googlebot – do not block them in robots.txt.
For multilingual sites, always use hreflang annotations in addition to language targeting. They help Google show the correct versions in search.
FAQ
Common questions
With caution. Redirecting based on IP without giving users a choice can annoy users who speak a different language. Better to show a banner suggesting the switch.
Googlebot usually sends Accept-Language: en-US. If you redirect it to a Russian version, that may confuse it. Better not redirect bots; serve a default version with a switcher.
Use 302 (temporary). A 301 could be interpreted as permanent, and you do not want to permanently tie a bot to one version.
Direct contacts
Discuss your project?
Share your goals and website context — I will suggest a practical next step.