Generally the last thing people think about when building a WordPress theme is search optimization.
Features and design come first, and search optimization generally comes last or not at all. This article will discuss a few easy steps to make your WordPress theme a little friendlier to search engines. More specifically I’ll concentrated on explaining why it’s a good idea to optimize your WordPress theme, what the key elements of good on page SEO are, and discuss today’s best practices for on page SEO when designing websites that use WordPress as a CMS.
Why do we need to optimize WordPress themes?
Most WordPress theme designers don’t worry too much about on page SEO optimization because there are plug ins that can handle that. While this is true, it’s best not to rely heavily on any plug in that you don’t maintain yourself. This is because plug ins may not always be compatible with future versions of WordPress and you don’t want to delay keeping your client’s software up to date because it relies on a plug in. Updates to plug ins can also cause problems with your theme down the road, leading to unnecessary time you’ll have to spend debugging your client’s website.
Key elements for better on page SEO
There isn’t a whole lot you can do for on page SEO, but that doesn’t mean it’s not important. We’ll look at the following best practices for on page SEO and then see how we can apply them to our WordPress themes.
- Using descriptive page titles.
- Having unique meta description for your pages and posts.
- Having clean URLs.
Descriptive title tags for WordPress themes
Your title tags should clearly describe what the content of the page or post is about and should be unique for every page. It’s also a good idea for the title to include your site’s name. Fortunately the default theme for WordPress does this out of the box. You’ll find the following code in the default theme’s header.php file:
<title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
This is great. However, if your using WordPress as a CMS you’re probably going to be using pages more often than posts and you may want to keep your page names to one word or less to keep your navigation menu at a reasonable size. For example your about page is most likely titled “about”. If this is the title for your page and you’re using the default WordPress title function, then your title will be “about « your site’s WordPress title”. This is fine, but we can do better by adding a few conditional statements in your header.php file.<?php if(is_page('about'))
{ echo the_title(''," us. We're a Tucson based web design company that specializes in developing sites with WordPress.");
} else { echo wp_title('«', true, 'right'); ?> <?php bloginfo('name');} ?>
What does this mean exactly? Basically this code tells WordPress to:
- Check to see if the page titled “about” is being viewed.
- If the page titled “about” is being viewed then display the page title preceded by nothing and followed by ” us. We’re a Tucson based web design company that specializes in developing sites with WordPress.”
- If it’s any other page or post, then display the page or post title and then the WordPress site title.
Before and after
As you can see the second title is much more descriptive and informative. This will not only help your website get better search engine results, but many users will find this useful as well. I recommend that you do this for all of your pages by using conditional statements. You can even go further by creating unique titles for all of your different post categories.
Creating meaningful meta descriptions
Meta keywords aren’t incredibly important when it comes to achieving better search engine results, so I don’t put much effort into these. However, having a good meta description for your site’s pages and posts is important. Some search engines use these descriptions when displaying results, and it’s these descriptions that can make the difference between a user choosing whether or not to visit your web site. Needless to say, it’s a good idea to make unique meta descriptions for all of your pages and posts.
The strategy
Much like the title tag, we’ll be using some PHP to get the results we want. By default WordPress doesn’t even include meta tags or meta descriptions, so basically anything we add is going to be an improvement. Here’s the code that I use:
<meta name="description" content="<?php if ( (is_home()) || (is_front_page()) ) {
echo ('The description you want to appear for your home page.');
} elseif(is_category()) {
echo category_description();
} elseif(is_single()) {
echo the_title(''," by your site's name. A good description of what you want to appear on single posts. ");
} elseif(is_page()) {
echo the_title(''," your site's name. A description of what you want to appear on your site's pages.");
} elseif(is_tag()) {
echo '-tag archive page for your site's name - A description for tag archives.' . single_tag_title();
} elseif(is_month()) {
echo "archive page for your site's name. The description you want to appear while viewing monthly archives" . the_time('F, Y');
} else {
echo "Your default description";
}?>">
In plain English what this says is:
- If this is the home page, then display this custom text.
- If this is a category, then show the category descrption. You could also change this to a custom description using echo, or even target specific categories using the category slug.
- If this is a single post, then display the title, a comma, and then your description text.
- If this is a page, then show the page’s title, a comma, and some custom text.
- And so on.
- If none of the above conditions are met, then use this default description.
Cleaning up your URLs
This is a very easy way to get better search rankings with WordPress and requires no knowledge of building themes or PHP. From your WordPress admin area navigate to settings » permalinks. Then click on the Custom URL radio button and paste the following:
/%category%/%postname%
This will make your URLs a bit longer, but they’ll be easier for search engines to index. Now if you follow the steps outlined above when building your next website published with WordPress you should be off to a SEO friendly start.
Nice write up on SEO for wordpress themes. Unfortunately with the number of SEO plugins available for WordPress nowadays people simply think that they can install a plugin and forget about doing any other SEO.
Thanks again
Mark
I just wanted to mention that the content itself needs to be optimized for keyword density. If you’re hitting all the wrong keywords, a website will most likely not show up in Search Engines (1st page) regardless of meta tags. Also things like alt text and image file names can be useful when it comes to SEO…..Great post, I truly enjoyed it!