Search Leads Logo png

Contents

Hreflang 101: An Implementation Guide for Beginners

Contents

Running a website targeting multiple countries? Use hreflang. It’s the only way for Google to know which version of your site to show users in different parts of the world.

 

Hreflang is a code that tells Google the language you use to write your content. It is primarily used for international SEO. If you have a website aimed at a specific country or region, hreflang can help Google know which version of your site to show.

 

But using hreflang can be challenging. Doing it wrong could cause SEO problems for your site.

 

Hreflang and why you need it

While hreflang is not difficult to implement, it can be tricky to get right if you’re running a website that targets multiple languages.

 

Hreflang is an HTML tag that tells search engines which version of your site to show users based on their language preferences and location. Without hreflang, your users may see the wrong version of your site or be directed to a 404 page.

 

Hreflang tags are placed in the <head> section of a webpage, and they look like this:

 

<link rel=”alternate” hreflang=”x” href=”URL”>

 

The “x” in hreflang=”x” is replaced with the ISO 639-1 code for the linked page’s language. For example, hreflang=”en” for English, hreflang=”de” for German, and hreflang=”es” for Spanish.

 

Hreflang tags indicate to Google and other search engines that multiple page versions are available, each intended for a different audience.

 

 

It can improve the user experience on your site and help you avoid potential penalties from search engines for serving duplicate content.

 

Hreflang is indispensable for international SEO. So if your website offers content in multiple languages or targets users in different countries, use hreflang tags. It ensures that users are directed to the correct version of your site.

 

How to use hreflang correctly

Hreflang enhances international SEO by helping search engines understand which language or region for which content is relevant. Hreflang tags are placed in the element of a page, and they look like this:

 

<link rel=”alternate” hreflang=”x-default” href=”http://example.com/”/>
<link rel=”alternate” hreflang=”en” href=”http://example.com/en/”/>
<link rel=”alternate” hreflang=”es” href=”http://example.com/es/”/>

 

Place hreflang tags on every page so Google can easily understand which versions of your site are available in which languages.

 

Specify the language and the region

The “x-default” hreflang tag indicates the page that should be served to users who do not fall into any other specified languages or regions. Say you have a page in English and Spanish but don’t have a specific page for users in France; you would use the “x-default” hreflang tag to tell search engines which page to serve those users.

 

 

Hreflang is essential for both country code and language code. Without hreflang, search engines might serve your content to the wrong region or country, which could result in a lower ranking.

 

You can add hreflang tags to both HTML and XML sitemaps. Attach hreflang tags on all pages of the same language or region. Hreflang tags are coded in the following format:

 

`<link rel=”alternate” hreflang=”x-default” href=”http://example.com/”/>`

 

The “x-default” hreflang annotation can be a catch-all if you have pages not intended for a specific region or language. The “href” attribute contains the URL of the alternate page. The “hreflang” attribute includes the region or language code for the alternate page.

 

If you’re using hreflang with an XML sitemap, add the following namespace to your sitemap: xmlns:xhtml=”http://www.w3.org/1999/xhtml”

 

You’ll also need to add the xhtml:lang attribute to each <url> element in your sitemap:

 

`<url>`

`<loc>http://example.com/</loc>`

`<xhtml:link rel=”alternate” hreflang=”es-ES” href=”http://example.com/es/” />`

`<changefreq>weekly</changefreq>`

`</url>`

 

Include a self-referencing hreflang tag on each page

Self-referencing hreflang tags tell Google that the page is meant for a specific region or language. Even if there isn’t another page version in a different region or language.

 

For example, if you have a Spanish version of your site, include a self-referencing hreflang tag on each Spanish page, like this:

 

`<link rel=”alternate” hreflang=”es” href=”http://example.com/es/” />`

 

Note that hreflang tags are only used for pages with various versions of the same content. So, if you have two pages with entirely different material (say, an English page and a Spanish page), then you would NOT use hreflang.

 

The first hreflang tag is the x-default tag, which tells search engines what to do if it can’t match a user’s location to any other hreflang tag on the page. The remaining hreflang tags specify the languages and regions in which the page is available. In this case, the page is accessible in English (en) and Spanish (es).

 

Hreflang can also target specific languages within the same country. For a website for English and Spanish speakers in the United States, use hreflang tags to target these two groups separately. Spanish speakers would see content written in Spanish, while English speakers would view it in English. Do this using hreflang tags with both language codes (en-us and es-us) and country codes (en-us and es-us):

 

<link rel=”alternate” hreflang=”en-us” href=”http://example.com/english”>

<link rel=”alternate” hreflang=”es-us” href=”http://example.com/spanish”>

 

Use hreflang self-referencing tags that point to other pages on your website to help search engines understand your content better.

 

Make sure your hreflang tags are well-formed

Hreflang tells Google which language the page is written in. x can be replaced with any ISO 639-1 code, like fr for French or en for English.

 

You can use hreflang for content on your site targeted at different language speakers on the same topic. For an article on how to make a perfect omelet written in French and English, hreflang can help Google understand that these two articles are similar, even if they’re in different languages.

 

Hreflang=”x” should always be accompanied by hreflang=”x-y”, where x is the language and y is the region. For example, if you were writing for users in France, use hreflang=”fr-fr” to advise Google what language the page is written in and what region it’s targeting.

 

Apply hreflang to direct Google to pages that don’t exist yet. If you’re planning to launch a new version of your site in a different language, add hreflang tags pointing to the non-existent pages on your site with a rel=”alternate” attribute. When the pages are created, Google will automatically discover them and index them accordingly.

 

You also need to identify the correct canonical URL for each page.

 

Following these steps will help you avoid common mistakes that can hurt your international SEO efforts.

 

Hreflang enhances your SEO

 

Hreflang tags tell search engines what language your content is in, so they can serve it to the right audience. These tags are crucial if you have a multilingual website.

 

Use hreflang annotations carefully, as too many or incorrect annotations can hurt your SEO.

 

Hreflang tags are just a piece of the puzzle in SEO – no magic bullet will guarantee top rankings. But used correctly, hreflang can be a valuable tool in your SEO arsenal.

 

Search Leads can help you use hreflang correctly, so Google will understand which versions of your site are available in which languages. Serve the right content to the right users. Connect with a Search Leads SEO specialist today.

 

Placeholder
Picture of Christopher Borlongan
Christopher Borlongan

Christopher is our visionary CEO and Head of SEO, seamlessly blending leadership with SEO wizardry. His strategic insights and engaging leadership inspires his team through innovative strategies and precision to achieve industry-leading growth.

Begin your journey towards groundbreaking success today!

Frame
Frame