Knowledge Base - Resources - seoClarity

H2 Tag Found Outside Body

Written by Suraj Lalchandani | April 26, 2023

<h2> tags are expected to exist in the <body> of a page. If your H2 heading tag is outside the body, it should be deleted and re-added in the appropriate location.

Table of Contents


Why H2 Tags Should Be in the <body>

Like an <h1> tag, <h2> tags are a way to structure the content on your pages and make it easier for both search engines and users to understand what a page may be about.

However, if an <h2> tag exists outside of the <body>, then search engines may not recognize it. This is a missed opportunity to offer crawlers more information about your page.
 

How to Move the H2 to the <body>

In order to move an <h2> tag to the <body>, the existing tag will need to be deleted. This solves the issue of having the tag be in the wrong location.

Then, you’ll need to re-add the tag to the correct location so that search engines can understand it.

Inspecting your pages can show you instances where the <h2> tag is present outside of the <body>. For example, an incorrect tag could look something like this:

<body> … </body>
<h2>Example Tag Outside Body</h2>

To start the optimization process, this incorrectly placed tag should be deleted. This can be done through your site’s HTML code. If you don’t have edit access to your site’s code, the dev team should be able to help you make the necessary changes.

Once the <h2> tag is gone, it can be re-added. Be mindful to put the tag within the <body>— a critical part to this optimization.  

Following the example, the correct code would look something like this:

<body>
<h2>Example Tag Inside Body</h2>
</body>

How to Optimize H2 Tags at Scale

These optimizations can be implemented site-wide, across thousands of pages with SEO execution platform ClarityAutomate. A few minutes is all it takes to add, delete, or update your <h2> tags.
 

Delete the <h2> tag that is outside the <body>

1. Select what you'd like to optimize: Code

Start by selecting “Code” in ClarityAutomate to make an optimization to an <h2> tag.

2. Choose how you'd like to optimize it: Delete

The existing tag needs to be deleted before it can be re-added to the <body>.

3. XPath location: XPath of the <h2> tag outside the <body> that needs to be removed

This step specifies the <h2> tag that will be deleted. 

Add the <h2> tag within the <body>

1. Select what you'd like to optimize: Code

Adding the H2 also requires a change to the code.

2. Choose how you'd like to optimize it: Add New

As opposed to deleting or updating, an element is being added.

3. XPath location: XPath within the <body> where you need the <h2> tag added

This step specifies where the new tag will go.

4. Code: The <h2> tag with the text you want added.

As a last step, enter the H2 code. Your changes are ready to be implemented!

Summary

If an <h2> tag exists outside the <body> it should be deleted and re-added in the appropriate location.

This optimization can be made site-wide with just a few clicks with ClarityAutomate.

Looking for other heading tag issues?