Duplicate Titles with Yoast’s WordPress SEO Plugin

Posted on

This is a ‘problem’ that’s perpetually swirling around the WordPress support forums. Here’s just one example.  I’ll be honest, I haven’t thoroughly combed through the code that hooks into the title and outputs the new “Yoast title”. I will however say, it works perfectly on many, many sites I’ve been using it on.

That being said, for each an every site I’ve initially installed it on, I’ve encountered this issue initially. If you follow the following workflow, baring any wild abnormalities or javascript conflicts, I’m certain you’ll experience similar results.

1st

You are going to want to set default templates. For the various aspects of your site. Aside from setting a default title format to be output for various pages, posts, tags, categories, etc, it resolves a lot of duplication issues.

At the bottom there is a reference for various formatting options. Pick your poison.

Keep in mind, whatever you use between your template tags will be output as well. In my case I generally use “|”. No go check your titles, see how they look now. Keep in mind Yoast has provided both a link to the home page and blog page on this very page. Edit that at will.

2nd

I took an additional step and manually customized my title a bit. To do such. You are going to want to locate your themes header.php file open it and locate:

<title><?php echo wp_title("") ?></title>

It’s possble that there could be something other the above between the title tags, but either way, I’ve replaced it with:

<title>
<?php
if(is_page('home')) { echo bloginfo("description"); echo " | "; echo bloginfo("name"); }
else if(is_home()) { echo bloginfo("name") . " | " . "Blog";}

else { echo wp_title(""); }
?>
</title>

A little explanation is in order…

First, we check to see if it’s the home page ‘is_page(‘home’)’. In my case, my home page is actually named “home”.  If it is, we output the “the blog info | the blog description”  These can be found  in the WP backend > settings > general. Note: If yours is something else, replace accordingly.

Then we us the is_home() conditional tag. This is misleading. You would expect it check to see if it’s your HOMEPAGE. What it ACTUALLY does, is check to see if it’s your main blog. Tuck that one away. That one tripped me up more then once before I committed it to memory. Regardless, if that returns true the output is: “The Blog info(name) | Blog”. Note: You can change Blog to whatever you see fit.

Finally , neither of these conditional tags are met output   “wp_title(“”);” and let Yoast do the rest. How’d it work for you?


Tags: , , , , , , , ,

Justin W Hall

Justin W Hall

Mostly a front-end web application developer by day. Sometimes asleep by night.

View Full Profile →

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

16 comments on Duplicate Titles with Yoast’s WordPress SEO Plugin

Leave a Reply