I have some errors with the hreflang tags
In this article, you will learn how to troubleshoot the most common error messages with hreflang tags.
This article is useful if you are managing a subdomain or a subdirectory integration on your website and not a JavaScript integration.
- What are hreflang tags?
- Common error messages
- No hreflang tags
- Conflict with your own custom hreflang tags
- Duplicate hreflang tags
- Canonical issues
- HTML lang attribute doesn't match
- Missing x-default
- Squarespace and Webflow
- Hreflang checker
1. What are hreflang tags?
As a key part of your SEO (Search Engine Optimization), hreflang tags are snippets of code that tell search engines like Google what language the content on any given page is written in so the search engines can serve that result to users searching in that language.
They look like this:
<link rel="alternate" hreflang="en" href="http://www.example.com/en/"/>
(with WordPress and subdirectory integration) or
<link rel="alternate" hreflang="en" href="http://en.example.com" />
(on subdomain integration).
2. Common error messages
Here are the most common error messages with hreflang usage:
- No hreflang tags
If your site has no hreflang tags, you'll need to copy-paste the hreflang links you will find in your Weglot Dashboard -> Select your project -> Setup page (for non-WordPress projects).
- Conflict with your own custom hreflang tags
You should have the exact same number of hreflang tags in your original version as in your translated version(s).
The hreflang tags must be identical in each URL contained in the hreflang tags. For example, if you have 3 hreflang tags:
<link rel="alternate" hreflang="en" href="http://www.mywebsite.com/" /> <link rel="alternate" hreflang="fr" href="http://www.mywebsite.com/fr/" /> <link rel="alternate" hreflang="es" href="http://www.mywebsite.com/es/" />
The same hreflang tags must be on all these pages.
Note: you can contact Weglot support so we can make sure not to add Weglot's hreflang tags.
- Duplicate hreflang tags
Make sure that you didn't add the Weglot hreflang links several times in your HTML source code or that you are not using another translation tool on your website in addition to Weglot.
Also, on Shopify websites, make sure that you don't have any registered language in your Shopify admin > Settings > Store Languages. If so, please unpublish and delete them. They are indeed something different from Weglot, and it can create some conflicts in the code.
- Canonical issues
Note that Weglot adds the hreflang tags but doesn't add the canonical tag in your HTML code, so you need to add the canonical tag on your side, as it can't be done by Weglot.
When the canonical is added, Weglot will then automatically replace the canonical tag with the right one regarding the current page. It means that if your original page contains a canonical, Weglot will automatically handle the canonical to respect the translated URL.
There are lots of scenarios that cause canonical issues, but here are a few of the most common, according to Google.
- HTML lang attribute doesn't match
The issue can be due to the fact that the value of the HTML "lang" attribute in your original content doesn't match with the hreflang tags added by Weglot.
For example, consider an HTML lang attribute set to "en-US" and a hreflang tag:
"<link rel="alternate" href="https://www.mywebsite.com" hreflang="en" />"
The "en" hreflang tag added by Weglot does not match with the "en-US" HTML lang attribute of the links it points to.
Therefore, you'll need to change the HTML lang attribute value in your original content to "en" instead of "en-US" to solve the issue. It's also possible that you have a plugin that could change this attribute value.
- Missing x-default
According to Google documentation, the "x-default" tag has to be added when no language matches.
Some SEO checkers advise adding an x-default tag. However, it can only be related to a homepage where no languages match.
For instance, when your homepage represents a language selection only. In this case, this page doesn't match any languages and so will need to be represented with the "x-default" tag.
Otherwise, your original version should have the hreflang tag regarding your original language.
- Squarespace and Webflow
Some error messages on Squarespace and Webflow can come from the fact that Weglot is not able to edit your original pages by default. When you set up Weglot and the subdomain integration, Weglot can only change the content of the translated pages, and it correctly creates the hreflang tags for all these pages.
In the translated versions, the paths are the correct full paths of the current URL. In the original content, though, Weglot can't access it and add the full path in the hreflang tags.
Here, you should be able to automatically manage the addition of alternative URLs with the relative URL of the page on the original version of your site, thanks to this documentation we created: https://github.com/weglot/integration-hooks.
With it, you will be able to have the correct paths in the hreflang tags of your original pages too.
However, please note that this isn't preventing Google from indexing your website, and the translated pages should be correctly indexed anyway
3. Hreflang Checker
It’s a good idea to check that your hreflang tags are working correctly. We’ve developed the Hreflang Checker tool for this very purpose.
Paste the URL that you want to check into the search bar and then click on the “Test URL” button.