The hreflang attribute should be implemented in the <head>, not outside of it. 

If your hreflang tag isn’t where it should be, you can delete it and re-add it appropriately. 

Table of Contents

Why This Is Important

If the hreflang resides outside the <head>, it may not be crawled by search engines. This means that the attribute may not be serving the purpose you think it is.

How to Update Hreflang 

The solution here is to ensure that hreflang attributes reside in the <head> tag on the page. 

You’ll need to delete the current hreflang and add it again in the correct location. 

To do this, you’ll need certain access permissions to your site’s code. If you don’t have those permissions, you may need to ask the engineering team to add the code to your website. 

Luckily, you can also use an SEO execution platform to implement the change on your own — all within a matter of minutes. Here’s how.

Solving the Hreflang Issue at Scale

Updating a page in which the Hreflang resides outside the <head> can be completed in two steps.

How to Delete Existing Hreflang

The first step of the process is to delete the current hreflang tag(s) that exist outside the <head>. You can do that using ClarityAutomate.

  1. Select what you'd like to optimize: Code
    In this example, we’re looking to delete the hreflang code from the <head>, so we start by selecting “Code” in ClarityAutomate.
  2. Choose how you'd like to optimize it: Delete
    This is where we specify that we want to delete the current hreflang tag.
  3. XPath location: XPath of the hreflang outside the <head> that needs to be removed
    This is where we set the XPath of the hreflang that we want to delete. 

That’s it! Push those changes live and the hreflang will be gone.

How to Add Hreflang in the <head> Section

Now that the original hreflang has been deleted, you can add it back in the correct location. 

  1. Select what you'd like to optimize: Code
    This is the same step as above, since we’re still dealing with hreflang and your site’s code.
  2. Choose how you'd like to optimize it: Add New
    In this case, we want to add new hreflang to the page.
  3. XPath location: XPath within the <head> where you would like hreflang  to be added
    This step ensures that you’re adding the new hreflang within the <head>.
  4. Specific Location: You can choose “Add before location” or “Add after location” depending on where you want it added
    You can adjust the specific location of the hreflang with ClarityAutomate.
  5. Code: The full hreflang that you would like added
    Lastly, enter the hreflang code. 

Next Steps

All that’s left to do is to push your changes live. ClarityAutomate lets you go through this entire process in a matter of minutes, so you can scale this process across your entire site. 


Looking for other hreflang issues?