CMSKite

Glossary · SEO

Hreflang

Hreflang is an attribute that tells search engines a page also exists in other languages, or for other countries, and gives the address of each version. Search engines use it to show a reader the version in their language, such as the Portuguese post to someone searching in Portuguese.

DashboardStart freeNo card. Your blog is live in a minute.

An example

A bakery writes one post in English, Portuguese and Spanish. The head of all three pages carries the same four lines: every version, itself included, and a default for everybody else.

In the head of each of the three posts · html
<link rel="alternate" hreflang="en" href="https://bakery.example/blog/wedding-cake-guide">
<link rel="alternate" hreflang="pt-BR" href="https://bakery.example/pt-br/blog/guia-bolo-de-casamento">
<link rel="alternate" hreflang="es" href="https://bakery.example/es/blog/guia-pastel-de-boda">
<link rel="alternate" hreflang="x-default" href="https://bakery.example/blog/wedding-cake-guide">

pt-BR is Portuguese for Brazil; es with no country is Spanish for anyone. x-default is the page for readers whose language is not in the list. The same set can go in a sitemap instead of the head.

Why it matters for a small-business blog

Most small businesses do not need it: one language, one blog. It matters when you write the same post for two markets, for example English for customers in the US and Portuguese for customers in Brazil. Without it, a search engine may show a reader the version they cannot read, and your two versions are left for it to work out on its own.

It does not translate anything, and it is not needed for posts that are different articles in different languages. It only connects versions of the same page.

Common mistakes

  • No return links. Each version must list itself and every other version. In Google’s words: “If two pages don’t both point to each other, the tags will be ignored.”
  • Made-up codes. The language comes first, in ISO 639-1 (pt, es), then an optional country in ISO 3166-1 Alpha 2 (pt-BR, es-MX). en-UK is wrong: the code for the United Kingdom is GB.
  • Listing a version that is not live. Each address in the set should be a working page. Add a version when it is published, not when it is planned.
  • Expecting it to set the language. Google works out a page’s language from its text; it does not use hreflang or the lang attribute for that. Hreflang only links versions that exist.
  • Leaving out x-default. It is optional, but without it nothing says which version suits a reader whose language you did not write in.

How CMSKite handles it

  • On the free blog link: automatically. Turn on more languages in a project and write each post’s versions in the editor. Every page then lists its published versions, plus x-default, and the blog’s sitemap carries the same set.
  • Through the API, your developer adds the tags. Each post comes back with translations: the language and address of every published version. Your site prints those in each page’s head or sitemap. Making your posts findable shows where the head tags go.
  • How we do it on cmskite.com. Our own blog is one CMSKite project with English, Portuguese and Spanish turned on. Each page reads its versions from translations, so a version appears in hreflang the moment it is published.

Sources

Questions

Do I need hreflang if my blog is in one language?
No. Hreflang only connects versions of one page in different languages or for different countries. A blog in one language has nothing to connect.
Where can hreflang go?
Google accepts it in the page’s head, in HTTP headers, or in a sitemap. The rule is the same in each: every version lists itself and all the others.

Checked