Tweaking Your WordPress Title Tags for Better Rankings

Summary: In this “blogtorial” I’ll explain why the title tags on your blog posts are important for search engine visibility, and I’ll show you how to tweak your WordPress template in order to optimize your title tags for better rankings.

Note: Before we go any further, I should specify that this blogtorial is intended for people who are running WordPress on their own website, as opposed to people who are hosting their blog under the WordPress.com domain. If you have the blogging program on your own domain, you’ll be able to do everything mentioned below.

Every business blogger wants his or her blog to show up in relevant search engine results. It doesn’t matter what kind of business you are in, or what blogging goals you have. Every business blog can benefit from better visibility online. You’ll get more traffic, more interaction and — in the end — more success from your blog.

This brings up the subject of search engine optimization, or SEO. This is the act of improving your website for better rankings in the search engines. Now, there’s a lot that goes into SEO when it’s done properly. So I don’t plan on covering all of it with this blog post. (Check out my collection of SEO tutorials if you want to get into the weeds.)

In this post, I’m going to offer a specific tip for one single component of search engine optimization. I’m going to teach all of your WordPress users how to tweak the code for your title element / title tag so that each blog post can enjoy better search engine visibility. It’s a simple change to make, and if you want to get right to it you can skip ahead to the “How to Tweak the Code” section below. But for anyone who is unfamiliar with this terminology, I’m going to start with a very short lesson on title elements and SEO.

What Is an HTML Title Tag Anyway?

HTML purists will correct me in my language usage here. They will say that it’s not called a title tag, but rather a title element. Fair enough. But I’m going to use the more popular term and refer to it as the HTML title tag. Sorry purists.

Basically, we are referring to a piece of HTML code that is found within the overall HTML code of a web page. And for the purposes of this tutorial, a blog post is a web page. Here is what a title tag looks when viewing the source code for a particular page or post:

<title>Search Engine Optimization for WordPress Users</title>

What is the purpose of this item? Well, it does several things. Primarily, it defines the title of the web page where it resides. So the example title tag I’ve written above might be found on an article about SEO for WordPress blogs — kind of like this article. Makes sense, right?

The title above is also written with both people and search engines in mind. For people, it’s written in a clear manner with relevant keywords that describe the content of the page. Why? Because it shows up in the search engine results page for Google, Yahoo, etc. [See the example below.] And, like the headline of a newspaper article, the title tag should be written to entice people. After all, you want them to click on your website through the results page!
Title Tag in Search Results
In the image above, you can see two important reasons for creating effective title tags. The first reason is search engine visibility. Search engines like Google use a variety of factors when ranking their results, and when matching a particular web page to a person’s search query. But the HTML title tag is high on the list of ranking factors.

You are essentially telling people and search engines alike: “This is what my web page is about. This title tells you what you’ll find when you visit this page.”

The title tag is also important because it works like the headline of a newspaper article. It should be written to pull people in. Remember, there are 10 results on ever page of a search engine query. So even if your blog shows up on the first page of results, there’s only a 1-in-10 chance somebody will click through to your site. How well you write your title tag will determine how many people click on it.

The Default Title Tags in WordPress

When you download the WordPress blogging program and install it onto your web host, it will already have all of the HTML stuff done for you. That’s the whole point of publishing a blog — you don’t necessarily have to worry about the HTML side of things, or even know how it works. You type your blog post in a user-friendly box, and the WordPress program converts it into HTML for you. All you have to do is click the “publish” button.

So how does WordPress come up with the HTML title tag for each post you create? Ah, now we are getting to the heart of the matter. It uses the title you create for the blog post, and then it puts that title into a formula that is designed within the coding.

However (and this is a big however), the default manner in which WordPress creates HTML title tags is not well optimized for search engine visibility. Why? Because by default, the program puts the title you created for your blog post toward the end of the HTML title tag, after a bunch of other stuff. The best practice for search engine optimization is to put that keyword-rich title at the front of the HTML title tag.

If you really want your individual blog posts to rank well for their particular subjects, you should tweak the WordPress code so that the HTML title tag comes from the title you give to the blog post … and from nothing else. In doing so, you also want to be sure that the main index page has a good title tag, that the category and archive pages have good title tags, etc.

There are many ways to do this, and I have tried most of them on my own WordPress blogs. I finally settled on what I feel is the best way to handle the title tags. Here is the code I use on this blog, as well as many others I publish:

<title>
<?php if ( is_home() ) { ?><?php bloginfo(’name’); ?> | <?php bloginfo(’description’); ?><?php } ?>
<?php if ( is_search() ) { ?><?php echo the_search_query(); ?> | <?php bloginfo(’name’); ?><?php } ?>
<?php if ( is_single() ) { ?><?php wp_title(”); ?><?php } ?>
<?php if ( is_page() ) { ?><?php wp_title(”); ?> | <?php bloginfo(’name’); ?><?php } ?>
<?php if ( is_category() ) { ?>Archive <?php single_cat_title(); ?> | <?php bloginfo(’name’); ?><?php } ?>
<?php if ( is_month() ) { ?>Archive <?php the_time(’F'); ?> | <?php bloginfo(’name’); ?><?php } ?>
<?php if ( is_tag() ) { ?><?php single_tag_title();?> | <?php bloginfo(’name’); ?><?php } ?>
</title>

You can see that this sets up different rules on how to handle the title tag, depending on where it occurs. For my single posts, it only uses the title I create for the blog post. For the home page, it uses the name and short description of the blog for the title tag. And for category and archive pages, it labels them appropriately as well.

This achieves many of the best practices for search engine optimization:

  • Each blog post has a unique title tag that reflects the content for that post.
  • Each title has keywords right up front, without any preliminary text to dilute it.
  • It allows me to write enticing titles for my blog posts, to pull readers in through search engines.

Best of all, it only takes me about 30 seconds to implement, across the entire site. I simply go to my Theme Editor and select the “Header” file. Then I look for the current code for the <title> tags, and I replace it with the code shown above.

A Word of Caution

I am not saying you need to make these changes. Do whatever is right for you. I’m just explaining what I feel is the best way to handle title tags on a WordPress blog. I would also urge you to use caution when making this or any other coding change to your template / theme. Before making changes, be sure you have a backup copy of the current HTML coding for whatever file you are changing. That way, if you “break” something with your changes, you can quickly and easily put the original code back into the file.