WordPress is a content management system. It allows the user to create and edit types of content, be them post, pages or custom post types and classify them with taxonomies, categories, tags or custom taxonomies. Almost every bit of content a WordPress site outputs is easy to control by the maintainer of that WordPress site. Almost, because there’s one piece of content that’s notoriously hard to fully control. That bit is the title, often also called “meta title”. The way that title is displayed is determined, in large part, by your theme.
Now I bring this up for a single reason: the title is the single most important piece of content on a page relating to SEO. In the most recent update of SEOmoz’s ranking factors, the presence of a keyword in the title was agreed by SEO’s to have an “influence value” of 94.4 out of 100. That’s huge.
In WordPress’ most recent default theme, dubbed Twenty Eleven, the content of that title tag is determined by the following code:
<title><?php /* * Print the <title> tag based on what is being viewed. */ global $page, $paged; wp_title( '|', true, 'right' ); // Add the blog name. bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " | $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) ); ?></title>
With all due respect, I hate that. The reason I hate that is that it means that on the front page of your site, no matter what you do, your title will always be of this format:
NAME OF SITE | DESCRIPTION OF SITE
On other pages, it will be:
NAME OF ARTICLE | NAME OF SITE
So we effectively hardcode in our design templates the way we output one of our most important bits of content on a page. That’s very far from the separation of design & content that the web community at large has been striving for over the last few decades.
If you’re now thinking, “hey, I’m using that theme and I have another page title for my homepage”, you might be right, I’ll get to that. The reason you’re able to do that is also the reason why I regularly get questions about my WordPress SEO plugin and theme X, Y or Z having issues with the title.
The bad solution: Output Buffering the page title
I don’t want to spend this entire article explaining what output buffering is, so if you don’t know, this is a rather simple explanation. This process is used by most big SEO plugins. What they do is: catch the output of a page, look for the
<title>, fix the contents of that title, return the output. For the record: if you check the “Force rewrite titles” box on the Titles page of my SEO plugin, it does just that. The reason my plugin has had issues with titles is exactly that: I don’t have that box checked by default.
Now one can argue over whether output buffering in general is a bad idea or not, the way it’s done here is arguably bad, although the only current working solution. It uses way more resources than should be needed to change the title and, possibly worse, it effectively disallows other plugins that don’t do the buffering to have an influence on the title. On top of that, in my testing, on most servers it adds about 0.5 seconds to the page load time.
The good solution: something new in core
For quite a while, I thought that changing the way we, as a community, use
wp_title would be a fix to this. I no longer think that it is. The reason for that is that it would create all sorts of other issues, with themes and plugins alike. In fact, Andrew Nacin already tried to do that a while back, see this changeset, and reverted the changeset because the output buffering plugins broke because of it. I think we need a new function, specifically aimed at displaying the page title. Ideally this function would hook into wp_head and would be using the theme_supports functionality.
I’ve been working with Andrew on a patch, which has been heavily discussed on this Trac ticket. I have good hopes that something along these lines will go into core, but would love to know your opinion.