How To Fix hreflang No Return Tags
Have you logged in to “International Targeting” section in Google Search Console?
Have you found the “no return tags” error?
What is it?
This article will show you how to fix this error.
If you already have a good idea what hreflang tags do then skip to the “How Do You Fix The No Return Tags Issue?” section of this article.
If you would also like an overview of what hreflang is and why we use them, keep reading.
Why You Should Use hreflang tags?
When you tailor your content to different regions such as the UK, CA and the US. Or when you use different languages such as English, French, and German.
You want to make sure that Google finds your content and shows it to the right customers.
This is where hreflang tags come in.
hreflang tags tell Google that the content is the same but written in another language or region.
Telling Google that you have content for a particular market such as the UK is smart. It improves search rankings for that page in the UK Google search results.
It also stops Google penalizing you for having the same content many times on your site.
Next, let’s look at what hreflang tags are.
What are hreflang tags?
hreflang tags contain two pieces of information.
The first is the language or region code.
The format should be language then region, for example:
en-GB
to show English for Great Britainen-US
to show English for the United States
It is also possible to set a language only, for example:
de
to show Germannl
to show Dutchfr
to show French
You can then mix and match the languages and countries, for example:
nl-BE
to show Dutch for Belgiumfr-BE
to show French for Belgium
The language or region code has to be in a specific format. A common error is when the language and region code is incorrect.
To help reduce the errors it can be useful to use an hreflang generator tool.
To recap you can have a language on its own or you can mix and match the language and region.
You cannot have a region on its own, this is not a valid hreflang and will cause an error.
Here is a full list of all the valid Language codes and the list of region codes.
When there is no matching language or region, Google will send users to the default language. You can define which page is the default language.
To do this we must set the language/region to x-default
.
The second piece of information on a hreflang is the page URL. This is the URL for the same content written in various languages.
Once you have these two pieces of information you are ready to set the tags.
How Do You Set Them?
There are three options to set hreflang tags:
- Add hreflang tags to the HTML
- Use HTTP headers
- Set them in the Sitemap
Let's go through each implementation.
Add hreflang tags to the HTML
We can link to all the alternative language pages using HTML.
Adding <link>
tags to the <head>
of the HTML will inform Google where the alternative content is.
The links are in this format:
<link rel="alternate" hreflang="lang_code" href="url_of_page" />
Where lang_code
is the language/region and the url_of_page
is the page URL.
For example, let's say we have an English version of our site at https://example.com/en
. We also have the same content in French and German the links on the page would look like this:
<head>
<link rel="alternate" hreflang="en" href="https://example.com/en" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr" />
<link rel="alternate" hreflang="de" href="https://example.com/de" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en" />
...
</head>
Here we have listed the alternate pages and we have set english to the default language.
You should also set the tags as high up in the head as possible, after the opening <head>
tag. This is because you want to make sure that it is readable before any external file requests.
Next, let's look at how we can do the same with HTTP headers.
Use HTTP headers
An alternative to setting them as HTML is to use HTTP headers. The content of the header is the same yet, it is not a part of the file but the request.
It is common to see HTTP headers used to return an alternate version of a PDF. As PDFs are not HTML based we cannot use the method above.
This is the format of the header:
Link: <url1>; rel="alternate"; hreflang="lang_code_1", <url2>; rel="alternate"; hreflang="lang_code_2", ...
In the above, we would replace the url
with that of the alternate page, for the various PDFs.
For example a request to https://example.com/en/file.pdf
would look like this:
Link: <https://example.com/en/file.pdf>; hreflang="en" rel="alternate";,
<https://example.com/fr/file.pdf>; hreflang="fr" rel="alternate";,
<https://example.com/de/file.pdf>; hreflang="de" rel="alternate";,
<https://example.com/en/file.pdf>; hreflang="x-default rel="alternate";"
Again, we have set the matching language code.
Next, we will look at setting these using the sitemap.
Set them in the Sitemap
Our last option is to use the sitemap.
This allows us to specify in the XML any alternate pages we may have.
On some sites, it can be easier to maintain the hreflang tags in one place. The sitemap gives us a single file to manage all the alternatives rather than in each of the HTML files.
To do this we must follow the following rules:
- The sitemap must start with
xmlns:xhtml="http://www.w3.org/1999/xhtml"
- Each URL is then added with the
<url>
element - Inside the
<url>
add a<loc>
element with links to the page URL. - Underneath the
<loc>
element we can then list all the alternate pages using the<xhtml:link rel="alternate" hreflang="supported_language-code">
element. This should also link to itself.
Using the example above for https://example.com/en
we would need to create a sitemap which looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/en</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="https://www.example.com/de"/>
<xhtml:link
rel="alternate"
hreflang="fr"
href="https://www.example.com/fr"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://example.com/en"/>
</url>
<url>
<loc>https://www.example.com/de</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="https://www.example.com/de"/>
<xhtml:link
rel="alternate"
hreflang="fr"
href="https://www.example.com/fr"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://www.example.com/en"/>
</url>
<url>
<loc>https://www.example.com/fr</loc>
<xhtml:link
rel="alternate"
hreflang="de"
href="https://www.example.com/de"/>
<xhtml:link
rel="alternate"
hreflang="fr"
href="https://www.example.com/fr"/>
<xhtml:link
rel="alternate"
hreflang="en"
href="https://www.example.com/en"/>
</url>
</urlset>
Now we know how we should be setting up these tags let's look at the “no return tags” issue.
How Do You Fix The No Return Tags Issue?
In the Google Search Console click on the legacy tools. Then click the “International Targeting” link.
You will see a list of all the HREFLang errors, something like this:
In the above image, you can see that there are a few “no return tags” errors.
To see what page is at fault click on one of the errors.
This will give you a list of pages with this error.
Content that is the same but written in different languages must have the same hreflang links.
The “no return tags” error means that one or more of the pages is missing the identical hreflang links.
Let's look at an example using the HTML tags.
Here the English page found at https://example.com/en
has set the following tags:
<head>
<link rel="alternate" hreflang="en" href="https://example.com/en" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr" />
<link rel="alternate" hreflang="de" href="https://example.com/de" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en" />
...
</head>
Yet, when we inspect the HTML for the French page https://example.com/fr
we find the following tags:
<head>
<link rel="alternate" hreflang="fr" href="https://example.com/fr" />
<link rel="alternate" hreflang="de" href="https://example.com/de" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en" />
...
</head>
We can see here that it is missing the English hreflang link.
And this is the cause of the “no return tags” error.
To fix this error you need to ensure that all pages have identical hreflang links.
Remember you may have to fix this in any of the following three locations:
- HTML Tags
- HTTP Headers
- Sitemap
To check that the new links are correct you can use a tool such as hreflang Ninja. When you give it your URL it will check that the links are working.
Wrapping Up, How To Fix hreflang No Return Tags
This article has given you an overview of hreflang tags.
Including where these tags live and how to write them.
We have discussed how to fix the “no return tag” error be ensuring that:
- All pages must have identical hreflang links.
- You must set a default language using the
x-default
language option - You cannot have a region on its own.