Language, charset, and hreflang for localized pages

International pages combine two separate concerns: correct text decoding and accessibility, and search engines choosing the right language or regional URL. The report checks charset and html lang locally, then validates hreflang codes, targets, return links, responses, and canonical conflicts.

At a glance

Every locale needs a stable crawlable URL and a complete relationship set

Serve UTF-8 consistently, declare the document language for browsers and assistive technology, and use fully qualified reciprocal hreflang annotations between equivalent localized pages. Each genuine language version should normally canonicalize to itself.

  • Declare UTF-8 early and send a consistent HTTP Content-Type.
  • Set html lang to the language of the visible page.
  • Give each locale its own crawlable URL instead of relying on cookies.
  • Make hreflang sets self-referencing, reciprocal, valid, and canonical-consistent.
01

Language and character encoding

A charset mismatch can corrupt text before any SEO signal is interpreted. Prefer UTF-8, declare it near the beginning of the head, and make the HTTP Content-Type agree with the document.

The html lang attribute helps browsers, translation tools, pronunciation, and assistive technology. Search engines may infer content language from visible text, so the declared value should describe the actual page rather than a site-wide default.

<html lang="en">\n<head>\n  <meta charset="utf-8">
02

Build a valid hreflang cluster

  • Valid code Use a supported language and optional region, such as en or en-GB; a country code alone is invalid.
  • Absolute target Include scheme and hostname and point to the exact equivalent page.
  • Self and return links Every version lists itself and the other versions; the targets point back.
  • x-default Optionally identify a neutral fallback for unmatched users, often a selector or default page.
03

Coordinate canonical and locale routing

Do not canonicalize all translated pages to one language when each version contains genuinely localized main content. Keep a self-canonical on each locale and connect equivalents with hreflang.

Avoid automatic language redirects that prevent users or crawlers from opening a chosen URL. Provide visible language links, return 200 for each version, and keep the same hreflang set in HTML, HTTP headers, or sitemaps without contradictory implementations.

Action checklist

Validate every locale as a complete page

  1. 01Standardize HTTP and HTML character encoding on UTF-8.
  2. 02Set the correct html lang value for each page template.
  3. 03Use a stable URL and self-canonical for each localized page.
  4. 04Validate codes, absolute URLs, self-links, and reciprocal hreflang links.
  5. 05Test locale URLs without cookies, geolocation, or Accept-Language.

Official references

The technical recommendations in this guide are aligned with these primary sources.