Knowledge Base - Resources - seoClarity

Invalid Language in the Hreflang Attribute

Written by Suraj Lalchandani | May 4, 2023

Wrong language codes in the hreflang attribute do not get picked up by Google. 

Luckily, incorrect hreflang language codes can be corrected with a few steps.

Table of Contents

What Language Code Should Be Used for Hreflang?

Search engines expect the region code in the Hreflang attribute to be in ISO 639-1 format. If you use the wrong language code, it will not get picked up by Google.

Here’s an example of the ISO 639-1 format:

<a target="_blank" href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes'">https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes</a>

How to Update Hreflang Language Codes

The solution is simple: update the invalid language codes to the correct format. Now, you can update language codes manually, but you may need to loop in the dev team.

How to Update Hreflang Language Codes at Scale

Another way to update language is to leverage ClarityAutomate, an SEO execution platform, to update your language codes at scale. 

This allows you to implement the fix with a few clicks, and resolve the issue in a matter of minutes — not days or weeks.

  1. Select what you'd like to optimize: Code
    The first step is to select what part of the site we’d like to optimize. In this case, it’s the code.
  2. Choose how you'd like to optimize it: Update
    We’re looking to update the language codes. There’s no need to delete or add anything here.
  3. XPath location: XPath of the <link rel=alternate> with the invalid language
    This step isolates the invalid language.
  4. Attribute: hreflang
    We can now focus on the hreflang attribute that needs to be updated. 
  5. New Value: The new value of hreflang with the correct language
    The last step is to set the correct value, that being the correct language code so that Google can pick up the hreflang. 

Before and After

You can use ClarityAutomate to update all applicable canonical tags across your entire site.

Here’s what the update looks like — notice the change from “eng-us” to “en-us”.

 

Looking for other hreflang issues?