WordPress SEO Tweaks Without Plugins

If possible I like to tweak WordPress installs and avoid adding extraneous plugins. Generally the more plugins you have, the slower your WordPress site loads, and you can have compatibility issues when you upgrade.

One area for consideration is duplicate content, and there are a number of excellent plugins available for handling duplicate content issues. All in One SEO Pack and Joost de Valk’s WordPress SEO Plugin are very good, however, for my personal requirements both these plugins add a lot of unnecessary functionality.

If you prefer full control over your WordPress source code, by making a few slight tweaks you can handle an SEO duplicate content issue using the Meta Robots tag and have more control over page titles. If you are new to SEO or the Meta Robots tag, you can read more about this element here.

Basically, I prefer to noindex,follow category (is_archive()), tag (is_tag()), search (is_search()) and pagination pages (is_paged()). This enables search engines to crawl the pages for links which are subsequently followed. Therefore, the blog homepage and individual posts are indexed as normal, but duplicate content issues with category and tag pages are avoided. Also other unnecessary pages that you wouldn’t want indexed and returned in search results are noindex,follow.

Meta Robots Tag

The code for enabling this feature is as follows, and needs to be included in your header.php file which can be found in your WordPress admin panel under Appearance > Editor > header.php.

<?php if ( is_tag() ) {
echo "<meta name=\"robots\" content=\"noindex,follow\">";
} elseif ( is_archive() ) {
echo "<meta name=\"robots\" content=\"noindex,follow\">";
} elseif ( is_search() ) {
echo "<meta name=\"robots\" content=\"noindex,follow\">";
} elseif ( is_paged() ) {
echo "<meta name=\"robots\" content=\"noindex,follow\">";
} else {
echo "<meta name=\"robots\" content=\"index,follow\">";
}
?>

You may choose to tweak the above code to enable indexing of category pages (is_archive()) for example. To do this, you would simply delete the line:

elseif ( is_archive() ) {
echo "<meta name=\"robots\" content=\"noindex,follow\">";
}

Title Tag

Another area for consideration is the page title. Again, there are a lot of plugins that make it easy to control titles for different pages. However, if you prefer manual control, you can add the following code to your header.php file which can be found in your WordPress admin panel under Appearance > Editor > header.php.

<title>
<?php wp_title(''); ?><?php if(wp_title('', false)) {
echo ' | '; } ?><?php bloginfo('name'); if(is_home()) {
echo ' | '; bloginfo('description'); }
?>
</title>

The above code basically includes the blog homepage title at the beginning of the title tag on the homepage, and includes the description taken from Settings > General > Tagline. On individual blog post pages, the post title is included on the left–hand side of the title tag, and the blog name is moved to the right–side of the title.

Title Examples

Homepage:
Robin Parduez | Blog | Front-end Development Tips & Ramblings

Blog post:
WordPress SEO Tweaks Without Plugins | Robin Parduez | Blog

Disclaimer

Please test any code changes that you make to your WordPress installation. Test your blog to ensure the meta robots noindex,follow tag is only applied to category, tag, search, pagination pages and index,follow is applied to the blog homepage and individual post pages. Be sure to test your page titles as well, they should follow the pattern shown in the examples above.

There are of course many more features available if you use an SEO plugin, and for some users a plugin will be suitable. You may also wish to tweak the code examples above to meet your needs.

If you have any comments or suggestions please feel free to give some feedback in the comments section below.