Tweaking WordPress Page Titles
My favoured structure for a home page’s title tag is
Title of site : Short description of site
and for other pages I like to use
Title of page - Title of site
It’s important to keep the most relevant information at the start, and having a descriptive element in the title of your home page helps clarify what it’s about and improves search rankings.
A lot of WordPress themes always put the site’s title first and don’t allow for a description. To change this, edit header.php to use:
<title><?php
if (is_home())
{
bloginfo('name');
echo ' : ';
bloginfo('description');
}
else
{
if (is_search()) echo 'Search';
else wp_title('');
echo ' - ';
bloginfo('name');
}
?></title>
The description part of the home page title will come from the tagline specified within the WordPress admin interface (if your tagline is too long, remove that line and hardcode a short description into the preceding echo).
Search pages have to be treated as a special case, as for some strange reason they’re not covered by wp_title.
Thu 14th Sep 2006, 3:38pm GMT
Filed under: Client-side Coding, Hints and Tips, Search Engines, Server-side Coding, Usability, Web, Weblogs
Comments
Comments are now closed for this entry.
Matt Round’s company blog, covering web development, media, technology and pretty much anything else.
- Web Sites
- Good-looking, effective, accessible sites.
- Multimedia
- Logos, Flash games, animation and illustration.
- Advice
- Help with strategy, planning and getting noticed.
