Perfecting Your WordPress Title Tags

WordPress‘ default theme (Kubrick) is great, but I’ve always had a problem with the title tags that the Kubrick theme generates. They could be so much more search engine friendly, don’t you think?

<title>

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

This usually results in the title reading like Interweb World » Perfecting WordPress Title Tags, which is fine.

But isn’t it better to serve the title tags with the title of the article first? That’s the key information, not what website it came from. And that title tag is what’s going to be used in people’s browser favourites, search engine results and social bookmarking services (del.icio.us, Digg, Stumbleupon, etc).

Improving your Blog Titles

I’ve opted for a simple bit of code which you can see below. Basically, for the homepage (<?phpis_home()?>), we want to display the Blog Name and it’s description or strapline. Then, for every other page (category pages included), we want the title to show up first, then the site name.

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

		<?php bloginfo(’name’); ?> &raquo; <?php bloginfo(’description’); ?>
	<?php } else { ?>
		<?php wp_title(”); ?> &raquo; <?php bloginfo(’name’); ?> 

	<?php } ?>
</title>

Looking good. Test this out on your own blog and see how you get on.

Modifying Title Tags for UltimateTagWarrior

If like me you use Christine Davis’ Ultimate Tag Warrior plugin for internal tagging, add the code below (just after the <?phpis_home()?> condition) and your tag pages will have the same effect.

	<?php } elseif (is_tag()) { ?>
		<?php UTW_ShowCurrentTagSet("", array(’first’=>’%tagdisplay%’, ‘default’=>’, %tagdisplay%’, ‘last’=>’ %operatortext% %tagdisplay%’)); ?> &raquo; <?php bloginfo(’name’); ?> 

Subscribe with Add to Google or Subscribe to netvibes

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <table> <thead> <tbody> <tr> <td> <h2> <h1> <h3> <h4> <h5> <div> <object> <embed> <param> <br>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal5>, <drupal6>, <javascript>, <mysql>, <php>. The supported tag styles are: <foo>, [foo].
  • Links to specified hosts will have a rel="nofollow" added to them.

More information about formatting options

To prevent automated spam submissions leave this field empty.
Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.