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.




54 Comments + Trackbacks
10.3.2008
Love the tip, and a double listing is fantastic for your site, but a word of caution. Plugins such as headspace2 (great SEO plugin) user the wp_title(); function exclusively to display the title tags that you assign from within the headspace plugin page. This could effect the way your title renders out.
Found that out the hard way – spent hours trying all different function combination to get headspace2 to work and all it needed was
10.3.2008
i’ve read about this as well. and i do see that in the serp results. now i just need to find a way to do this in blogger.
10.3.2008
@Jamie: Thanks for your great advice! But seems like you forgot the end of your sentence :p
@koujie: I don’t know if this is possible on blogger, I never used this platform. You should definitely set up a WP blog!
10.3.2008
Hi Jbj,
you can also use a plugin All in One Seo Pack or Platinum Seo Pack which provides similar options without any modification in the code.
P.S : I understand that “purists” person prefer to edit code.
10.3.2008
@Maigret: Thanks for mentioning All in one SEO Pack, which is one of the best WP plugin ever! Btw, I think that theme developers should provide users a SEO optimized title, even if All In One SEO Pack can do it: The more features your theme have, the best it will be
10.4.2008
Woops! I think i put in html and it filtered it out. It needed just (table)(?php wp_title();)(/table). Just replace the ( with the proper html tags
10.4.2008
Hi
Wonderful post and great tips. The post and comments helped me a lot. I saved this page for future reference. Thanks once again for sharing such a lovely information with us.
10.4.2008
Great post. Thanks for the tip.
10.7.2008
Good and interesting post. I’ll use a plugin but it’s interesting to see the code.
What do you think of the coment relish plugin ? I’ll do a post about it.
See you,
Camille JUNG.
10.7.2008
Hey young brother
I never tried the comment relish pugin. If you’re looking for a killer SEO plugin, give a try to All In One SEO Pack, you won’t regret it!
See you soon
10.8.2008
It is interesting to see how it is coded. I personally use All In One SEO Pack because it allows you to set the keywords and description meta tags as well.
10.9.2008
Great post. Saves me some time in having to write new code for the title. Your suggested titles, especially when it comes to the title of a blog post. Most of the focus is taken away from your post when put on the blog’s name and the word “wordpress” in the search engine results.
10.9.2008
Great post, I have quite a bit of work to do myself in better optimizing my titles. I am using all-in-one-seo yet I typically don’t do enough market research the reap the full rewards of my blog posts as it stands now.
10.10.2008
That makes so much sense. After all the effort one puts into SEO for the content and if one only used the title tag correctly it makes so much difference.
10.10.2008
Most important thing is to have H1 tag around the single post title. And another thing, on single post the keywords and page description should be appropriately chosen. All-in-one-SEO plugin can do this job pretty well and can increase your search traffic hitting single posts dramatically.
Cheers,
Ajith
10.12.2008
Great advice! Optimizing your title tags is so important yet most themes ignore this critical piece of the puzzle.
10.14.2008
Thanks for the tips. I think most people are doing Main Keyword | Long Tail Keyword and I think this is a good trick too..
10.15.2008
I should pay more attention to this aspect as I don’t tend to notice what my mind goes for during a regular search. Keeping in mind that it comes out name/category/article will allow me to notice what others have set their conditions up as.
10.15.2008
Always interested to hear more SEO related stuff – but my understanding was that keyword relevance was most important – therefore, if your blog name, category name and article title all have important relevant keywords in them – where’s the harm in them all appearing?
10.16.2008
This is a great help. tags should be powerful. i will try the code too.
Stellar
10.20.2008
Thanks for lovely tip.:)
10.21.2008
Thank you for the code, it works perfectly. I use it in the comments.php instead for the line of text “If you would like to comment on …..” with tags getting some extra keywords.
10.21.2008
@Convert to: you’re right, this is a nice use of this code!
10.26.2008
I used this code:
“”
but it wasn’t the best variant so i edit my header.php and use your code,
thank you very much,
Shoto Azikuri.
10.28.2008
Thanks for the share because it is very useful. I sometimes prefer self hard coded add-ins in wordpress more then plugins because they tend to overload already very big wordpress pages. And this is great replacement for SEO title plugins that are available.
10.31.2008
Thanks for the tip on the plug-in, have you found wordpress or blogger (or any others) to more cooperative with your SEO strategies?
11.2.2008
sir is it just for WP ? what about typad platform ?
11.4.2008
Personally I would use the All-in-one-seo-pack for Wordpress. This allows you full control of your titles so you can optimize every page individually. It is easy to install too.
John
11.6.2008
Cool tip,have already tried it , also doing some split testing, will send the results soon.
11.11.2008
Thanks Buddy, I found your site from http://delicious.com/tag/seo
and really, it’s very helpful for me. as i changes my WP title.
Thanks again dear.
11.12.2008
Always interested to hear more SEO related stuff. And I’m realy love to find any tips how to code my wordpress and optimising the theme rather than using plugins
11.13.2008
Great tips. Thanks.
Seems that Platinum Seo Pack is the way to go.
11.24.2008
First i used Alll In One SEO Pack, but my friend suggest me to change to platinum seo.
I din’t like the way the Platinum SEO appear on Google. Do have any suggestion?
Which one should i used? Or it still have the same result..
12.31.2008
Thank you very much. Since switching themes, I didn’t notice that my titles/descriptions had gone to hell… I’ll be sure to fix this at once!
1.3.2009
SEO is very good to get best rank in search engine but need to spend long time to best result. Patient also is important thing and must do more study about the SEO optimizing. If you are really master on SEO its like you can easy success on what ever blog platform you create beside the wordpress
2.12.2009
I started writing an SEO – Link building series last week… Some of the points discussed here will be of use to me to articulate it in beginners’ language.
One of the common questions that was asked there is the difference between keywords, tags and categories
2.14.2009
Excellent pointers to keep in mind. Personally after many years of SEO, I think the best way is just to hardcode/rewrite the titles and just leave your Keywords in the title tag of that page and nothing more. For example, your KWord is “Weird Tshirts” your title will only need to contain “Weird Tshirts” . I’ve noticed this to be more useful for optimization.
2.23.2009
Great pointer, I love to use the All in one SEO plugin, it’s been really helpful for managing multiple blogs and making sure the SEO principles stay in tact.
3.24.2009
Save my day, thanks for sharing
God Bless u
4.15.2009
Great Article, Thanks
5.29.2009
I’m newbie so I don’t know much about wordpress and how to SEO.
Thank you for this post.
6.4.2009
I don’t quite remember, but doesn’t SEO-all-in-one plugin allows you to do the same stuff without editing header.php?
It’s not a big deal to edit, but using a plugin could be less intrusive I think.
10.7.2009
hi Jean, i checked your front page and i think you don’t have an h1 there at all. you start at h2 – first, i think that’s invalid html. second, i think you can put the site title and small description in an h1 and get a lot more attention in search engines.
oron mizrachi
10.11.2009
Had some trouble adding the page titles for each post. Maybe my version of word press is newer. I downloaded the platinum seo plug in and everything worked fine. Thanks for your info, and SEO advice!
11.6.2009
Great hack!
A little tip if your blog’s got a static homepage;
replace is_home() with is_front_page()
This way you don’t get the static-page-title on your homepage.
1.6.2010
Thanks for the tips, everyone. But I have a question. I am using the “Page Meta” plugin for WordPress and I can’t figure out how to change the Title and Meta Description of my blog’s main page. I don’t want it to be just the name of my blog. That particular plugin works for entry pages but not archives or my main page. Does anyone have a tip for me? I’m not sure that stein’s tip will work for my site.