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.
- 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. - Choose how you'd like to optimize it: Delete
This is where we specify that we want to delete the current hreflang tag. - 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.
- 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. - Choose how you'd like to optimize it: Add New
In this case, we want to add new hreflang to the page. - 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>. - 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. - 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?
- 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 URL Is Invalid
- Invalid order of Hreflang values
- No self-referencing Hreflang tag
- Hreflang Using Relative links