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.
- 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. - 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. - 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. - Attribute: hreflang
Then, you select “hreflang” in ClarityAutomate. - 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?
- Conflicting Hreflang and rel=canonical
- Hreflang with multiple defaults
- Invalid region in the Hreflang attribute
- Invalid language in the Hreflang attribute
- Hreflang with Duplicate Language/Region Combinations
- Hreflang Missing Language Entry
- Underscore Instead of Dash in Hreflang
- Empty Hreflang URL
- Hreflang Not Present
- Hreflang Present Outside <head>
- Hreflang URL Is Invalid
- No self-referencing Hreflang tag
- Hreflang Using Relative links