The language code must precede the country code to have a valid hreflang attribute. If your order is invalid, you can update the hreflang to swap the order and resolve this issue. 

Here’s an example to visualize the issue:

Correct: hreflang=“en-us”

Incorrect: hreflang=“us-en”

Table of Contents

Why Order Matters in Hreflang

Google expects the language code to precede a country code. If the values in a hreflang attribute are in reverse order, it’s not valid. That means search engines won’t follow the instructions set by the hreflang. 

Updating Hreflang Values

The solution here is simple: ensure the language code precedes the country code. If your order is incorrect, you can update the hreflang code. 

You’ll only want to rearrange the order of the country and language codes. If all other elements like the href URL are in place, they’ll require no changes of their own.

In order to do this, you may need help from the dev team. Or, you can make the update yourself if you have the proper edit permissions to change your site’s code. 

Updating Hreflang Values at Scale

A second way to update your hreflang values is to use an SEO execution platform like ClarityAutomate. The technology lets you scale your implementation across thousands of pages, all with just a few clicks. 

Here’s the quick step-by-step process that can be applied in ClarityAutomate to fix the issue of an invalid order. 

  1. Select what you'd like to optimize: Code
    You can optimize multiple areas of your site with ClarityAutomate, but since hreflang is part of your site’s code, that’s what we’re concerned with. 
  2. Choose how you'd like to optimize it: Update
    As opposed to adding or deleting elements, we want to update existing hreflang to change the order. 
  3. XPath location: XPath of the hreflang with the invalid order of hreflang values. 
    This step narrows in on the hreflang that we’re looking to update. 
  4. Attribute: hreflang
    Then, you select “hreflang” in ClarityAutomate.
  5. New Value: The new value of hreflang with the correct order of hreflang values.
    Just like that, you’re able to set the new value of hreflang and push the changes live!

Before and After

Notice how this hreflang originally included “us-en”. Now, we’ve updated it to correctly say “en-us”. 


 

Looking for other hreflang issues?