Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client needed to adjust hreflang tags for
different regional versions of their website. Specifically, they wanted to
change 'en-usa' to 'en-us' and set regional codes like 'en-x-emea' and
'en-x-apac'. Additionally, they encountered issues where changes were not being
saved and received an error stating 'The hreflang already exists.'.
Solution:
We advised that the hreflang formats like 'en-x-emea' or 'en-x-apac' can be set from WPML -> Languages by adjusting the hreflang as needed.
To resolve the issue of the hreflang not saving (because the Enlgish language was used before, and as a result the hreflang "en-us" was already set to it), we suggested:
1. Activate the default English language on WPML -> Languages.
2. Change the hreflang for the default English language if it was previously set to 'en-us'.
3. Save the changes.
4. Attempt to change the hreflang from 'en-usa' to 'en-us' again and save.
5. Remove the default English language on WPML -> Languages if no longer needed.

This process helped in correctly setting up the desired hreflang tags. If these steps do not resolve your issue or if the solution seems outdated, we recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If problems persist, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 12 replies, has 2 voices.

Last updated by jordanP-2 9 months ago.

Assisted by: Marsel Nikolli.

Author Posts
May 8, 2024 at 9:33 pm #15607907

jordanP-2

Hi,

I have a few issues with hreflang tags. I'm sure I'm just missing something in the settings, but I can't figure it out myself.

1. I need to change the hreflang for the North America version (hidden link) from en-usa to en-us. I tried doing that on the languages settings page (see attached screenshot) but it doesn't save. After I click the Save button, the page refreshes and the hreflang is still en-usa.

2. Because we're targeting regions instead of countries, my SEO consultant recommended changing the hreflang for the EMEA (hidden link) and APAC (hidden link) sites. How can I change the hreflang to "en-x-emea" and "en-x-apac" respectively? In the same spot as the screenshot?

3. My SEO consultant also said the hreflang="x-default" should be self-referencing. In other words, when I'm on hidden link the tag should be this:
<link rel="alternate" hreflang="x-default" href="hidden link" />

It's currently this:
<link rel="alternate" hreflang="x-default" href="hidden link" />

The x-default should be the North America site because I'm in the United States.

I'm somewhat confused by hreflang, so please let me know if any of this doesn't make sense. Thank you!

Screenshot 2024-05-08 at 2.20.23 PM.png
May 9, 2024 at 9:56 am #15609810

Marsel Nikolli

Hi,

Thank you for contacting WPML Support, I will gladly help you.

The standard way how the hreflang attribute is added to the website is hreflang=”de-DE”. Where "de" is the country code and "DE" is the language value.

As per my knowledge you can't use the format "en-x-emea" or "en-x-apac" as a hreflang.

More information can be found in: hidden link

* On the attached image are shown your actual hreflang attributes.

Let me know if you have more questions.

Kind regards,
Marsel

Screenshot 2024-05-09 114758.png
May 10, 2024 at 5:27 pm #15615950

jordanP-2

Hi Marsel,

Thanks for the reply. I'll work with our SEO consultant and see what she says.

Is there a way to turn off the hreflang option in WPML? So we can add it another way?

This situation is kind of odd because we're targeting regions instead of specific countries.

May 10, 2024 at 6:36 pm #15616196

jordanP-2

Hi Marsel,

I got a little more clarity from my SEO consultant. She said that en-x-emea is valid as a regional tag, which is different from a country code. Country codes are better than regional codes for SEO, but my client decided to go the regional route.

Does WPML support regional codes? If not, that goes back to my question from a little while ago: Is it possible to turn off the hreflang that WPML provides?

Thank you!

May 13, 2024 at 9:19 am #15619459

Marsel Nikolli

Hi,

I understand the situation, and you should be able to set "en-x-emea" from WPML -> Languages, by changing the hreflang as needed without problems (section marked in the attached image).

* If you still keep having the issue when saving the WPML -> Languages -> Edit Languages
the page just refreshes and doesn't save anything, let me know.

Kind regards,
Marsel

15607907-Screenshot_2024_05_08_at_2.20.23_PM.png
May 13, 2024 at 5:17 pm #15622114

jordanP-2

Hi Marsel,

Thank you! I was able to set the en-x-* hreflang for the two regions I wanted. However, when I try to change en-usa to en-us, the page just refreshes (after I hit save) and the hreflang goes back to en-usa.

May 14, 2024 at 8:08 am #15623788

Marsel Nikolli

Hi,

From the debug info I've noticed that you are using WP v6.4.3, I suggest you update to the latest version.

Also, according to your debug.info, the WP memory limit needs to be increased, WordPress uses 40Mb as default and the minimum requirements for WPML are 128 MB. (Kindly check this page: https://wpml.org/home/minimum-requirements/)

You can increase it by adding the following code in your wp-config.php file right before the line: /* That's all, stop editing! Happy publishing. */

/* Memory Limit */
define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '256M');

* Note: Please make sure you have a full backup of your website before making any updates/changes to your website.

After following the WP update and the memory limit increase try clearing the website's cache and check if the issue persists.

Looking forward to your reply,
Marsel

May 14, 2024 at 7:02 pm #15626815

jordanP-2

Hi Marsel,

I noticed something I didn't see before--when I try to change en-usa to en-us, I get a "The hreflang already exists." error.

I think this part of the issue is related to something I've been working on in another support thread: https://wpml.org/forums/topic/sitemap-showing-non-existent-pages/ Not sure if you want to close this one out, since you were able to help me with the other hreflang tags.

Thank you for your help!

May 15, 2024 at 8:10 am #15628166

Marsel Nikolli

Hi,

The error: "The hreflang already exists.", shows when the hreflang you are trying to set is already in use by a language in your website.

Did you set the hreflang to "en-us" before for any of the languages?

May 15, 2024 at 3:57 pm #15631650

jordanP-2

Hi Marsel,

Yes, I believe I did use it previously. Because my client wanted 3 different "versions" of English, I had some issues setting it up initially. I think I created an en-us hreflang previously. How do I remove it?

May 16, 2024 at 9:16 am #15634066

Marsel Nikolli

Hi,

Thank you for the update.

I would need temporary access to your site's WP-admin to check out this issue. Please create an administrator user using any email address you prefer.

Please fully back up your site (files and database) and confirm it in your next reply.

Your next reply is set to private for you to provide the username and password details.

Thanks,
Marsel

May 17, 2024 at 8:23 am #15638048

Marsel Nikolli

Hi,

Thank you for the access, I was able to check and it should be set correctly. What I did was:
- activate the default English language on WPML -> Languages
- changed the hreflang for the default English language (as it was set to "en-us")
- saved the changes
- after, I changed the hreflang from en-usa to en-us
- saved the changes
- removed the default English language on WPML -> Languages

Please check and let me know if you have any questions or issues.

Kind regards,
Marsel

May 17, 2024 at 5:35 pm #15640626

jordanP-2

Hi Marsel,

I can see that it's fixed on dev. What I don't understand is how to activate the default English language on WPML -> Languages. Can you give me directions on how to do that? I'm probably missing something obvious. 🙂

Thank you!

May 17, 2024 at 5:47 pm #15640632

jordanP-2

Oh, wait, I figured it out! In case it's helpful for anyone else (or if I need a reminder in the future)
1. Go to WPML -> Languages
2. Click Add / Remove Languages button
3. Select English and click Save
4. Click Edit Languages link
5. Adjust the hreflangs as needed

Thank you so much for your help, Marsel.