Knowledge Base - Resources - seoClarity

Underscore Instead of Dash in Hreflang

Written by Suraj Lalchandani | May 4, 2023

If your hreflang uses an underscore instead of dash, you can update the attribute to solve this issue.

Otherwise, the hreflang attribute is invalid. Here’s how to do it.

Table of Contents

Why to Avoid Underscores

Google’s specifications for hreflang say the use of underscores (i.e. _) should not be used to separate the language and country. Instead a dash should be used (i.e. -)

For example, we would want to use “en-us” as opposed to “en_us”. 

How to Switch from an Underscore to a Dash

A simple change of your hreflang code can change an underscore to a dash. This can be done if you have access to your site’s CMS and direct edit access. 

You can also put in a dev ticket. 

Updating Hreflang at Scale

While a manual approach can get the job done, the project may land at the end of the dev team’s queue. Luckily, you can update your hreflang tags at scale with ClarityAutomate, an SEO execution platform.   

This allows you to update your hreflang with a few clicks and solve the issue in a matter of minutes. Plus, you can get the job done without involving the dev team. 

Here’s how to do it in a few steps.

  1. Select what you'd like to optimize: Code
    Since hreflang is a part of your site’s code, that’s what we’re looking to optimize in ClarityAutomate.
  2. Choose how you'd like to optimize it: Update
    This issue involves a change to the existing attribute (as opposed to an addition or deletion) so we select “Update”. 
  3. XPath location: XPath of the <link rel=alternate> with the issue
    Selecting the XPath location lets us narrow in on the specific issue.
  4. Attribute: hreflang
    The attribute we’re looking to update is hreflang, so we simply select that in this step.
  5. New Value: The new value of hreflang with a dash instead of underscore separating the language and country
    As a last step, we can specify our change and replace those underscores with dashes. 

Before and After

Notice how “en_us” has been updated to “en-us” after just a few steps with ClarityAutomate.

 

Looking for other hreflang issues?