Recently I was working with a domain which is configured for multiple languages. I was using my favorite theme which I use right here, U-Design. U-design is easily the most well documented, maintained and supported theme I have found to date and fully compatible with large plugins such as WPML and WooCommerce.

Incorrect hreflang implementation

I noticed this error in Google Search Console. For the site I was working with, this was very low priority. The error did not seem to adversely affect rankings for the English or the Spanish page.

WPML Problem

I have notified WPML of the issue.

The issue I was having is the Spanish page had an hreflang tag to a URL of what the home page would be if it weren’t the home page.

For example:

  • domain.com/es/ – the Spanish page
  • domain.com/ – the Home page
  • domain.com/home/ – the page the Spanish page kept linking to

In a perfect world the code on the /es/ page would look like this:

<link rel="alternate" hreflang="es-ES" href="./"/>
not:
<link rel="alternate" hreflang="es-ES" href="./home/"/>

The Solution

The fix is to go in to WPML settings and go to the “SEO Options” area and change the setting from “as early as possible” to “later in the head section”, and click save. Once it is saved, you can revert back to “as early as possible” and click save again.

screenshot

screenshot of the setting in WPML version 3.3.8.

This should fix the problem which is a WPML bug.

If you go to WPML support you will be given the whole “change themes and run debug” runaround. I am very happy with the WPML plugin and people but I’m sure this is a very common problem that has a very easy fix.

I hope this helps someone!

Len

Leave a Reply