PHP Magic Book – Free PHP Scripts, Tutorials and Downloads, PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips

Optimize Blog Post Title Tag For SEO

From SEO point of view, the title tag is one of the most important tags of webpage. The title appears as a link in search engines results and social bookmarking sites. We all download free WordPress themes and use. Most WordPress themes display the title tag in a non-optimized way. Here We shall customize this to obtain SEO-friendly and logical title tag for our blog.

Let’s modify the way your WordPress theme displays the title tag at different parts of your blog.

Open the header.php file from your theme in your favorite editor.
The code used to generate the title tag might look like following:

<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> ยป Blog Archive <?php } ?> <?php wp_title(); ?></title>

According to this code the blog title will be always displayed, never mind on which page the visitor is (i.e. search, post page, page, archives page, tag page etc).

Most of the time the visitor didn’t care about the blog title, he is just looking for info. And having the blog title displayed in all your title tags might make Google think it is duplicate content. And if not it still will appear at all search results from your blog. Why not at specific post the post title be displayed in beginning and blog title can follow, so that when search engine displays it, it will display most part of post’s title in search result. You get the idea…

We will use WordPress conditionnal comments in order to generate different titles depending where the visitor is:

On the header.php file, replace the code we saw before (The title generation code) by this one:

<title><?php if (is_home () ) { bloginfo('name'); }elseif ( is_category() ) { single_cat_title(); echo ' - ' ; bloginfo('name'); }
elseif (is_single() ) { single_post_title();}
elseif (is_page() ) { bloginfo('name'); echo ': '; single_post_title();}
else { wp_title('',true); } ?></title>

This code will generate title tags according to the following model:

  • Title for blog homepage: display the blog name.
  • Title for category page: display the category name and the blog name.
  • Title for article page: only display the article title.
  • Title for static page: display the blog name, and the page title.
  • Share/Bookmark
Tags: ,
Posted in: Hacks, WordPress
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Related Posts




One Response to “Optimize Blog Post Title Tag For SEO”

  1. Sep 29, 2009
    Raleigh SEO Says:

    Having the blog title displayed in all your title tags might make Google think it is duplicate content.

Post a Comment

  Subscribe Via RSS
  Subscribe Via Email