This is a followup response to Everfluxx, who wrote a post about the robots meta tags that Thesis inserts into archive pages.
Everfluxx discovered that when you opt to add the noindex attribute to your pages’ robots meta tags, Thesis automatically assumes you meant noindex, nofollow. However, the nofollow attribute can cause a loss of site-wide PageRank, so many Thesis users will probably need a way to remove it.
For a complete explanation, check out this must-read post from Everfluxx:
Using Thesis? Then beware of the “hidden” nofollow on archive pages!
In his post, Everfluxx describes the problem and proposes a solution. His solution is quick and easy, but it requires editing Thesis core files, which makes some bloggers nervous (since they would have to redo that code edit every time a new version of Thesis is released). In his closing paragraph, Everfluxx writes:
A final word to fellow Thesis developers/hackers: if you can think of a Better Way To Do It that does not require editing the theme files (e.g., via WP hooks, I dunno), please drop it in the comments. Thanks
I was in the mood for some php coding, so I set to work and made it happen. But…it was just too beautiful to leave as a comment…so I kept it all to myself! (Sorry, Everfluxx! If it’s any consolation, I’ve used hot pink throughout this post…in your honor! =P)
How to Customize Your Robots Meta Tags in Thesis
- UN-check the boxes under Add Noindex to Archive Pages in the Thesis Options menu. (The code below will add the robots meta tag for you, so if you leave the Thesis options checked…you’ll end up with 2 robots meta tags on each page.)
- Copy the code below and paste it into your
custom_functions.phpfile. - Edit the robots meta tag that corresponds with each page type to suit your specific needs. I have included a variety of page types already, but feel free to delete the ones you don’t need. For more-advanced customizations, reference the WordPress conditional tags.
- Promote this post for me by clicking the social media widgets below.
// Define your motherfuckin' meta robots tags
function my_mofo_meta_robo() {
if (is_home())
$mofo_robo = "<meta name=\"robots\" content=\"index, follow\" />\n"; // HOME PAGE
elseif (is_single())
$mofo_robo = "<meta name=\"robots\" content=\"index, follow\" />\n"; // SINGLE BLOG POSTS
elseif (is_page())
$mofo_robo = "<meta name=\"robots\" content=\"index, follow\" />\n"; // PAGES
elseif (is_category())
$mofo_robo = "<meta name=\"robots\" content=\"index, follow\" />\n"; // CATEGORY ARCHIVES
elseif (is_tag())
$mofo_robo = "<meta name=\"robots\" content=\"noindex, follow\" />\n"; // TAG ARCHIVES
elseif (is_author())
$mofo_robo = "<meta name=\"robots\" content=\"noindex, follow\" />\n"; // AUTHOR ARCHIVES
elseif (is_date())
$mofo_robo = "<meta name=\"robots\" content=\"noindex, follow\" />\n"; // DATE ARCHIVES
elseif (is_search())
$mofo_robo = "<meta name=\"robots\" content=\"noindex, follow\" />\n"; // SEARCH PAGES
elseif (is_404())
$mofo_robo = "<meta name=\"robots\" content=\"noindex, follow\" />\n"; // 404 ERROR PAGE
echo $mofo_robo;
}
// Add your motherfuckin' meta robots tag to the <head> section
add_action('wp_head', 'my_mofo_meta_robo');
{ 15 comments… read them below or add one }
Elegant solution, thanks for sharing! :)
I’m also flattered by the custom-colored link… Hope you don’t mind if I reciprocate. ;)
Thanks for the solution :).
This is pretty slick. One question though, why add the index,follow though? Why not if it’s the home, single page, category, just leave it blank? I’m not sure it matters, but since that’s the default it seems unnecessary.
Excellent question, Jennifer Lopez!
You’re absolutely right…there is no functional difference between using
<meta name="robots" content="index, follow" />and using nothing at all.The reason why I included those lines of code is because I wanted to provide my readers with an easy solution that doesn’t require them to add code. It’s much easier for someone to start with too much code and delete what they don’t need, rather than starting with one example and trying to duplicate it.
However, for my readers who are extraordinarily retarded…I tried to write my examples in a way that would suit most websites’ needs, on the off-chance that they just dump this code into their theme and don’t edit it at all.
Also, some readers will notice that this code doesn’t have to limit itself to robots meta tags. Therefore, if they wanted to add other elements to their pages’ head sections, they can easily edit the example code that’s already in place. For example, let’s say you needed to verify site ownership for Google Webmaster Tools. You could change this:
$mofo_robo = "<meta name=\"robots\" content=\"index, follow\" />\n"; // HOME PAGEto this:
$mofo_robo = "<meta name=\"google-site-verification\" content=\"j3nn1f3rl0p3z157h3c00l357m0zz3r1n7h3w0rld\" />\n"; // HOME PAGEThat makes sense. Although really you could also change it to this, no?:
$mofo_robo = ""; // HOME PAGEIf you were so inclined, and wanted to keep unnecessary code out of the page. Although that’s really just being nit-picky. I like this fix and am glad people are talking about it. Nothing worse than not understanding the depth of having a
noindex, nofollowmeta on a page.In order for the newline character (\n) to work in php, it needs to be wrapped in double quotes. Since the meta tag also uses double quotes, they need to be escaped with a slash, otherwise php will interpret them as the termination of our string. I don’t want to use
$mofo_robo = ""; // HOME PAGEin my example, because it invites end-users to simply paste HTML between the double quotes, which would result in an error. For example, if an end-user pasted their robots tag like this:$mofo_robo = "<meta name="robots" content="noodp, noydir" />"; // HOME PAGE…then php would read it like this:
$mofo_robo = "<meta name="robots” content=”noodp, noydir” />“; // HOME PAGEThat explains it. :) Thanks for your diligence in answering my questions! :D
Phew! *wipes forehead*
This isn’t really a solution as I have pointed out on the Everfluxx post – you might as well just install an SEO plugin
It should really be done as a filter or complete function replacing the current interface with something that works.
People use Thesis for client projects – having interface elements that are broken just isn’t a viable choice.
I’m not sure I understand your point. You took time out of your day…to stop by my blog…just to tell me that I haven’t really found a solution…because my function doesn’t replace the Thesis admin menu?
I just want to make sure I’m understanding you correctly, before I commit to writing a 1000-word comment explaining why what you just wrote is the single-dumbest thing anyone has ever said on this website.
Hopefully, I’ve misread your comment, and what you meant to say was: “OMG! You are brilliant! This is a fantastic solution–not only to my Thesis/nofollow woes, but to every problem I’ve ever encountered! After reading this post…my sites all rank #1, my marriage is stronger than ever, and my checkbook is balanced! You are my idol, and I worship you! Long live SEO Mofo!”
If that were the case, then I wouldn’t have to write that 1000-word comment…which would be quite a relief. ‘Cause that’s a lot of words.
I’d love to be proven wrong, Andy, but I’m afraid the Thesis options interface cannot be “replaced” or fixed via a single external function: months ago I looked into the Thesis source code just to realize that altering the default behaviour of that interface (e.g., introducing “nofollow” as a stand-alone option) would require rewriting the theme core. But that’s something the professional developers at DIY Themes are supposed to do, not (super-power-awesome) users like Darren. ;)
So what you are saying is that something complex like this might be left for a client to tool about with and then complain when their SEO breaks? Much as I hate edit and past solutions maybe having no interface for the client might be what is needed sometimes?
Write the 1000 words, it might be thereputic
Long live SEO Mofo!
p.s. Interesting choice on the new logo – display none rather than something using negative offset
Are you suggesting Google understands
display:none;, but notposition:relative; bottom:999999999em;?I know 10+ different ways of doing it, I haven’t got data stating Google prefers one method over another other than if there is an image link and then a separate text link they might take the text link in preference, and if it is nofollowed you might be screwed – need more tests.