Technical SEO

What is hreflang and how do I set it up?

Reviewed 2 November 2026 by the SageRank team

Short answer

Hreflang is an annotation that tells search engines which language or regional version of a page to show to which users. Each version lists every version, itself included, using language codes such as en or ar, and the links must be reciprocal: if page A points to page B, B must point back to A.

Example for an English and Arabic pair

<link rel="alternate" hreflang="en" href="https://www.example.com/" />
<link rel="alternate" hreflang="ar" href="https://www.example.com/ar" />
<link rel="alternate" hreflang="x-default" href="https://www.example.com/" />

Put the same three lines in the head of both pages. x-default names the version to show when no language matches.

Rules

  • Reciprocal. Every version must reference all the others and itself. One-way links are ignored.
  • Valid codes. Use ISO 639-1 language codes, optionally with an ISO 3166-1 region such as en-gb.
  • Absolute, canonical URLs. Use the exact canonical address of each version.
  • Real equivalents. Only link pages that are translations or regional variants of each other.

Other ways to declare it

You can send hreflang in HTTP headers, or list it once for every URL in your XML sitemap with xhtml:link entries. Pick one method and keep it consistent so the signals never disagree.

How SageRank helps

SageRank is built in English and Arabic, and keeps its own hreflang pairs reciprocal in both the page heads and the sitemap.