WordPress SEO: How to optimize the title tag for search engines

In terms of SEO, the title tag is one of the most important things: In fact, the title appears as a link in search engines results and social bookmarking sites. Unfortunely, most WordPress themes displays the title tag in a non-optimized way. Let's see how we can change that to obtain a really SEO-friendlt title tag.


As you can see on the above screenshot (Sorry for the French language!), by default, WordPress displays Blog name → Category → Artcile name in the title tag.

Though, we can see on the screenshot that Google truncated an important part of the article title. If the blog name and the category haven’t a lot of importance for the visitors, (They’re looking for some info, and don’t care who published it) the isn’t the case of the missing terms.
For exemple, there’s a huge difference between “6 tricks and tips to create your premium” and “6 tricks and tips to create your premium WordPress Theme“!

The solution to this problem is to modify the way your WordPress theme displays the title tag.

To do so, open the header.php file from your theme. The code used to generate the title tag might look like this:

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

As we can see, on that code the blog title is always displayed, nevermind on which page the visitor is.
Though, as I said before, most of the time the visitor didn’t care about the blog title, he’s just looking for info. And having the blog title displayed in all your title tags might make Google think it is duplicate content.

To achieve this hack, we’ll 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:

  • If the visitor is on the blog homepage: We’ll display the blog name.
  • If the visitor is on a category page: We’ll display the category name and the blog name.
  • If the visitor is on an article page: We’ll only display the article title.
  • If the visitor is on a static page: We’ll display the blog name, and the page title.


And you, do you have any tips and tricks to enhance the way your blog appears in search engines results? Let me know.