SEO Tip: Give your WordPress blog a unique H1

By | August 29, 2010 at 9:00 am | One comment | Web Development | Tags: ,

I manage a few WordPress blogs as do most people involved in SEO, and I have run into a similar problem with all of them – the ability to specify a unique H1 on just the homepage whilst the blog & category titles are the H1’s throughout the rest of the blog.   The majority of WordPress blogs do not allow you to do this and replicate the Blog Title throughout the website.

There are several ways of changing your WordPress template to allow you to setup a unique H1 for your homepage.  By default, the majority of WordPress templates have the H1 setup as following:

<h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>

In the case of my blog, I decided that I would change the WordPress template to show a snippet of text on only the homepage of my blog. To do this I replaced the H1 in the header.php file with a <p> tag, amended the CSS so the style was the same and then added the follow line of PHP text to the index.php file:

<?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>

<h1>Custom H1</h1>

<P>Custom intro text</p>

<?php } ?>

Whilst this is acceptable for most blogs, I have encountered instances where I needed to leave the default H1 in its current position on the homepage (such as a replacement logo or strapline) and show it as a <p> tag on all other pages.

To achieve this, you can use the following lines of code in the header.php file:

//If the page is only the homepage with post snippets print out the Blog Name as an <h1>

<?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>

<h1><?php bloginfo('name'); ?></h1>

<?php } ?>

//If the page is NOT the homepage, then print out the Blog Name as <p> tag.

<?php if(!is_home()) { ?>

<p><?php bloginfo('name'); ?></p>

<?php } ?>

In the instance above, I have set custom classes to replicate the styles so that to the end user the blog looks the same, but for the purposes of SEO I have created a unique H1 to increase relevancy on the homepage of the blog.

About the Author

Kev Strong

Kev Strong is an online marketing consultant at Newcastle Upon Tyne based digital marketing agency, Mediaworks. A lover of all things search and an ex-web developer, Kev Strong (a.k.a Goosh) is a specialist in advanced search engine optimisation.

One Comment

  1. Kopi (3 years ago)

    Is any plugins to get simple solution for this case ?

Comments