Skip to main content

What is hreflang, and when does your site need it?

The Tasadr team · ·3 min read

hreflang tells Google that pages on your site are versions of one piece of content in different languages or for different countries, such as an Arabic version for Saudi Arabia, one for Egypt and one in English. Each version must point to the others, and Google then shows each visitor the best fit.

Also known as hreflang · hreflang tag · rel=alternate hreflang · language and region tags · هرفلانج · وسم اللغة

On this page (7)
  1. What is hreflang?

    It is an annotation you place on a page to tell Google that the page has other versions in other languages or for other countries, and to list their addresses. Google then shows each user the version closest to their language or country.

    Google does not use it to detect a page's language. It uses it to link versions. The language follows ISO 639-1 and the optional region follows ISO 3166-1, so Arabic for Saudi Arabia is ar-SA, for the UAE ar-AE and for Egypt ar-EG. You cannot write a country code on its own.

  2. Which hreflang rules do most sites break?

    The first rule is that pages point to each other. If the Arabic page points to the English page and the English page does not point back, Google ignores the tag. The second is that each version lists itself along with the others, and the third is that the values carry valid codes. For a visitor whose language matches no version, use the x-default value.

    Google's hreflang rules
    RuleWhat is neededExample
    Return linksEach version points to the othersArabic points to English and back
    Self-referenceEach version lists itselfThe ar-SA version lists its own address
    CodesA language, then an optional regionar-EG, not EG alone
    Fallbackx-default for visitors no version fitsA country selector page
  3. An Arab-market example: a travel company with versions for three markets

    An illustrative example. A fictional travel company at gulf-travel.example has a packages page in three versions: Arabic for Saudi Arabia, Arabic for Egypt, and English for everyone. The packages and prices differ.

    In each version it places a list of annotations naming all three and itself, ar-SA, ar-EG and en, and adds x-default for a page where visitors choose their country. An Egyptian traveller is then less likely to meet the Saudi packages in a search result. That is a preference Google weighs, not a promise.

  4. What steps should you take to write hreflang correctly?

    Pick one method that is easy to maintain. The three are equivalent to Google. What matters is that the signals are correct and reciprocal.

    • Place link elements in the head, or in an HTTP header, or in the sitemap: one of them, not all three.
    • Make each version list itself and every other version.
    • Use valid codes such as ar-SA, ar-AE and ar-EG.
    • Add x-default for a country or language selector page.
    • Do not machine-translate pages without review, as in machine-translated pages.

Sources

  1. Tell Google about localized versions of your page · Google Search Central ·

Frequently asked questions

Why does Google ignore my hreflang?

The commonest cause is that the versions do not point to each other. Google says the tags are ignored if two pages do not both point to each other. Another is wrong codes, such as a country code on its own.

Do I write ar or ar-SA for the Arabic page?

Write ar if one version serves all Arabs. Write ar-SA, ar-AE and ar-EG if each market has its own version with its own prices and details.

Do AI engines need hreflang?

Google names no such requirement. Still, clearly separated versions for each market help any engine find the page that suits an asker in their country.