
You know it: SEO is a very important part of your blog because without a good seo, you’re loosing lots of potential visitors. In this recipe, I’m going to show you how to optimise the <title> of your blog for a better SEO.

You know it: SEO is a very important part of your blog because without a good seo, you’re loosing lots of potential visitors. In this recipe, I’m going to show you how to optimise the <title> of your blog for a better SEO.
Open your header.php file for edition. find the <title> tag, and replace it by the following code:
<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:
The result of this recipe can be seen on WPRecipes as well as on my other blog Cats Who Code.
26 Responses
The wpSEO Plugin makes it automatically.
I use the “All in One SEO” plugin which let you do this and a lot of other valuable stuff. Secondly I would recommend that before you use any of these things you do a little study on SEO to make sure you’re targeting the right keyword terms.
I also use All in One SEO pack, but this article is very good for those who want to make a SEO WP Theme
Best regards,
Chris
But why use a plugin when you can do it so simply and elegantly like Jean-Baptiste has it?
Plugins eat up memory, and if you’re on shared hosting you have to watch things like resource usage.
Jean-Baptiste, thank you for publishing this. The SEO plugins have been too bulky for my taste, and this will do the job beautifully. Already added to my header. Thank you again.
There’s a lot of good and complete SEO plugins, that’s a sure thing! But in my opinion this recipe is useful for the following reasons:
1) As Plurkr said, if you’re a theme designer, it’s always better to use a SEO-friendly title, even if the user can use a plugin which will do the same job.
2) As Sue said, if you have lots and lots of plugins, your blog can load slowly. Also, sometimes you just need one feature from a plugin, not all the options.
Glad to see that you liked this recipe anyways
I agree that all points are valid and the way to go ahead depends on your purpose and situation. But understanding SEO will still be a requirement to get things right as this recipe might be great if you have though SEO into naming categories etc. of your blog but if you didn’t then you’ll not get the full benefit.
Thanks a lot guys, but i have a plugin for the same thing
Regards.
Here is another, with a bit more complex coding.
<title>
<?php if ( is_home() ) { ?><?php bloginfo(‘name’); ?> | <?php bloginfo(‘description’); ?><?php } ?>
<?php if ( is_search() ) { ?><?php bloginfo(‘name’); ?> | Search Results<?php } ?>
<?php if ( is_author() ) { ?><?php bloginfo(‘name’); ?> | Author Archives<?php } ?>
<?php if ( is_single() ) { ?><?php wp_title(”); ?> | <?php bloginfo(‘name’); ?><?php } ?>
<?php if ( is_page() ) { ?><?php bloginfo(‘name’); ?> | <?php wp_title(”); ?><?php } ?>
<?php if ( is_category() ) { ?><?php bloginfo(‘name’); ?> | Archive | <?php single_cat_title(); ?><?php } ?>
<?php if ( is_month() ) { ?><?php bloginfo(‘name’); ?> | Archive | <?php the_time(‘F’); ?><?php } ?>
<?php if (function_exists(‘is_tag’)) { if ( is_tag() ) { ?><?php bloginfo(‘name’); ?> | Tag Archive | <?php single_tag_title(“”, true); } } ?>
</title>
—Frosty @ WPCult
curiosity: what do you think is better to use for the single_page?
1) post title
2) post title | blog name
For example I prefer using the first version – only the post title…
@Plurkr,
I would always go for the post title and leave out the blog name. And the reason it two-fold:
1) You need to construct your post title for optimum SEO usages (that includes conversions so that people seeing it in the search engine result will want to click it).
2) Unless you’re trying to build a brand (with the name of your blog) it will not help you achieve anything. The more text in the title the less each word will “mean”.
@Agolf Cartson another reason to only use the post name is for the case in which a user adds the post to a Social Bookmarking Service [eg: del.icio.us]
In my opinion it’s “ugly” to see the blog name in the end of the link.
So, I totally agree with you: “Unless you’re trying to build a brand (with the name of your blog) it will not help you achieve anything”
I use only posts titles. What Plurkr said about social bookmarking is true, and also this is the same with google search results.
Great, simple way to do this without the need for a plugin, I personally am trying to trim the resource demands of my wordpress blog, and tricks like this will help.
-So, I totally agree with you: “Unless you’re trying to build a brand (with the name of your blog) it will not help you achieve anything”
I disagree. For starters if your website is johns blog at johns-blog.com and your website is about blogging. The title will hold allot of wait. Kind of 1 and 1 million odds of that though.
But the reason I tend to add my site name is, studies have shone people are more likely to click on a link if they know where it’s heading. Nobody wants to click on “FREE EBOOKS”, but
if it were “FREE EBOOKS Johns Blog” – less likely to be a garbage site.
Last pointer, not to drag this on, NO search engine will dock you any amount of ranking for adding your site name to the title, Nor will it dilute any of your keyword/phrase weight by enough to matter. Go to any SEO site, they will all recommended doing this. Trust me it’s what I do for a living! hehe.
cool, i’ll be sure to use this on my site
Wow….
That’s very Usefully…
Hi,
I have a wordpress blog and I have enabled tagging. But I see that when i hover the mouse on the tags which is placed on the right side bar, i see the path as: http://blog/tag/tag-name
here the /tag after blogname and before the actual tag starts.
This is the value that it sets by default if there is no entry in the TAG_BASE. But I don’t want this /tag/.
can anyone help me with this.
for title tags we also had a plugin seo custom title where we can add out title customly
Trackbacks: