How to fix missing H1 tag issue on Astra theme home screen

I noticed a warning in Bing Webmaster Tools about a missing H1 tag. This happens when your site title is not set as an H1 tag on your home page, search results, categories, etc. Since all pages must include an H1 tag, we took steps to fix it to improve SEO.

I previously found two H1 tags and changed the site title to a tag. But this time I got an error that there is no H1 tag in the home screen, search results, and categories.

The current site title has been changed to an a tag to avoid the error of having two H1 tags in a post. Therefore, if you change the site title back to an H1 tag, the error of having two H1 tags will occur again.

After reviewing several documents for a solution, I was able to resolve the missing H1 tag issue by finding a code that changes the site title to an H1 tag only on the home screen, search results, and categories.

So let’s take a look at what the missing H1 tag error is and how to add code to keep the site title as an a tag in posts and change it to an H1 tag in non-posts.

H1 tag missing error message

Missing H1 tag

Bing Webmaster Tools can help you find major SEO issues, and the message states that the missing H1 tag. As mentioned earlier, this issue occurs because the site title is set to an a tag on the home screen, search results, and categories.

In the case of posts, since the title is set to the H1 tag, this problem does not occur even if the site title is the a tag. So, let’s look at the code that keeps the a tag as it is when the site title is a post, and converts it to the H1 tag on non-post pages such as the home screen, search results, and categories.

How to fix missing H1 tags

The solution is to change the site title to H1 tag or a tag depending on the condition. To do this, go to the theme editor.Add code to functions.php fileHave to.

// Function to change the site title to h1 or a tag based on conditions
function custom_astra_site_title($title) {
    // Change to h1 for home, archive, and search result pages
    if (is_home() || is_archive() || is_search()) {
        return '<h1 class="site-title"><a href="' . esc_url(home_url('/')) . '">' . get_bloginfo('name') . '</a></h1>';
    } else {
        // Keep as a tag for other pages
        return '<p class="site-title"><a href="' . esc_url(home_url('/')) . '">' . get_bloginfo('name') . '</a></p>';
    }
}

// Filtering the default title of the Astra theme
add_filter('astra_site_title', 'custom_astra_site_title');

Adding the above code will change the site title to h1 tag on home, archive and search results pages, and keep the a tag on other pages (posts). After adding the code,After clearing the cache, check with the following methodYou can do it.

Appearance with code applied

Missing H1 tag

If you press the F12 button on your browser to enter developer mode, you will see an arrow-shaped icon in the upper left corner. After clicking this icon and moving the mouse pointer to the site title, you can see h1.site-title as shown above.

It is basically an a tag, but it is changed to h1 on the home screen.

Missing H1 tag

When you go into the post, you will see that it has changed to an a tag. The code is working fine, so now you should check in Bing Webmaster Tools to see if the error is gone.

Check in Bing Webmaster Tools

Missing H1 tag

If you select ‘Inspect URL’ from the left menu of Bing Webmaster Tools, enter your site address, and perform an inspection, you will still receive an error. However, this is before it is reflected, so you can try inspecting it with a live URL.

Missing H1 tag

If you do a live URL check, you can see that there are no SEO issues as shown above. You can check the text and the missing H1 tag has been fixed. Currently, there is an error message, but the correction will be reflected over time and the error message will disappear.

This error can only be checked in Bing Webmaster Tools, and can identify various problems. Therefore, if you are running WordPress, please continuously monitor Bing Webmaster Tools to check for errors.

▶ How to install dual WordPress on CyberPanel

▶ How to fix /feed/ duplicate pages in Google Search Console

▶ 404 Error: Key Things to Check When You Get a Sitemap Not Found

Leave a Comment

Your email address will not be published. Required fields are marked *