Update: Excessive use of “nofollow” attribute is not recommended. Instead of using “nofollow”, it would be better to delete the links you don’t want to have them to rank high.
This is a follow up article to my most recent writing about Managing Your PageRank Flows. In the article I wrote about blocking PR leaks by nofollowing links to pages which aren’t vital getting a high ranking on search engines.
The pages to be considered, where and how you can nofollow the links are as follows. Basically you need to find a code which says a href and then add rel=”nofollow” between the “a” and “href”:
- the links to your own homepage – usually they can be found in the header.php or footer.php and embedded in a code looks like this:
<a class="on" href="<?php echo get_option('home'); ?>/" rel="nofollow">Make Money Blogging</a>
All you need to do is adding rel=”nofollow” like the above to block the link.
- your feed links – find any codes that says links to your feed and add rel=”nofollow” in similar manner as above.
- your date archive links – you can either delete the links if most of your blog’s content is not time based, or follow the instructions using a plugin below.
- page navigation links – usually shows up in your index.php file, look for the phrase “Previous Entry” or “Next Entry” or anything depends on your theme. Add a rel=”nofollow” between “a” and “href” within the code.
- links to enlarged pictures – same as above, add the rel=”nofollow” to the linking code.
- commentator names – this is by default nofollowed
To add nofollow to links beyond this point requires modifications to your original WordPress script. Please back up your WordPress files before comitting the mods since I can not be held responsible for any errors that may occur. There’s also a WordPress plugin that allows you to do nothing at all to WordPress files, but it requires a little bit more coding knowledge, though. I’ll ahow you right after this section.
Find the functions within the following files and add rel=”nofollow” between every “a” and “href” inside the function:
- wp_generate_tag_cloud, get_the_category_list, get_the_term_list within the file /wp-includes/category-template.php – this will add nofollow to tag cloud and category links.
- edit_post_link within link-template.php – this will add nofollow to “Edit this post” link if you’re logged in as your blog’s admin.
- the_author_posts_link within wp-includes/author-template.php – this will add nofollow to author links. An easier method is available if your blog only has one author is to delete all the links referring to the author’s page.
- comments_popup_link within wp-includes/comment-template.php – this will add nofollow to links within the comment section.
Now, I’ll show you the plugin Stephan Miller told me which enables you to add nofollow without having to touch the WordPress original files at all. First, please download the Add Link Attribute plugin and activate it. According to the instruction, you need to replace the function calling the linking codes within your blog’s theme with the plugin’s own function.
For example, I’ve done nofollowing my pages link using the plugin. What I did was, I looked for the codes to display the pages links on my header. I found them inside header.php. It originally looked like this:
<?php wp_list_pages('title_li='); ?>
Then, I replaced the codes with the plugin’s function:
<?php add_link_attr('wp_list_pages', 'title_li=', 'rel="nofollow"'); ?>
Now I’ll try to explain what to be included within the code and how it can be applied for other functions.
First, the original code from the function looked like this:
<?php add_link_attr('function', 'arguments', 'attribute', imgtag); ?>
Then, you need to alter the word “function” with the function you want to replace. In my case, it was the function displaying the pages links, which was wp_list_pages. How can I know which functions to replace? Easy. Look for them inside your theme codes.
Therefore, after knowing which fucntion to be replaced, the plugin code will be like
<?php add_link_attr('wp_list_pages', 'arguments', 'attribute', imgtag); ?>
Next, you need to replace the word “arguments” with the value usually accompanying the function you want to replace. The value is written within the brackets after the original function’s name. In my case the function wp_list_pages was originally written wp_list_pages(‘title_li=’). That makes the plugin code appears like
<?php add_link_attr('wp_list_pages', 'title_li=', 'attribute', imgtag); ?>
Not so difficult, isn’t it? Further, the “attribute” word is where you write any attributes you want to add. Since we’re talking about adding nofollows to links, then the “attribute” will be replaced with rel=”nofollow” so it looks like
<?php add_link_attr('wp_list_pages', 'title_li=', 'rel="nofollow"'); ?>
That leaves one more word in the plugin’s function to be replaced, that is imgtag. Since the instructions says:
imgtag (boolean) Insert attribute(s) into img/image tag ( TRUE), or into a/anchor tag (FALSE). Defaults toFALSE.
and we’ve got nothing to do with it, we can leave the value empty. Finally, the final form of the code to add nofollow to pages links will be:
<?php add_link_attr('wp_list_pages', 'title_li=', 'rel="nofollow"'); ?>
For more explanations and examples of this great plugin, please go to the plugin’s homepage.
I guess that’s all and I hope you find the tutorial useful. Drop any of your questions below and I’ll try my best to assist you.





Am I correct when I say this;
That when you add a nofollow to your links the search engines cannot find them. So the only way to get the search engine to recognize them is to create a sitemap.
I believe that WordPress has a plugin that will allow you auto generate your sitemap for your blog.
Then this scenario of nofollows will work well.
~ Jim
To make your pages hidden at all, it’ll be better to use the NOINDEX tag on individual pages or controlling access using robots.txt. Because with nofollow, your page will still appear in search results if there’s another site linking to your page. http://googleblog.blogspot.com/2007/02/robots-exclusion-protocol.html
We can also use sitemaps for that purpose. Here’s a sitemap plugin I use. http://www.arnebrachhold.de/redir/sitemap-home/
very good post. I did not know any of this and will start adding it to my sites. Thanks for the help. Take care.
Bills last blog post..Fannie Mae & Freddie Mac Bailout
I don’t recommend getting rid of all the links to the homepage by using no follow. It is beneficial to have 1 link in the footer or elsewhere with SEO’ed anchor text. I agree though that all links to “Home” should be no followed.
That works too. But at times I would like to see how ranks are passed more to my individual posts.
Two points here:
1) Instead of making all those changes to core files, you should consider using Platinum seo plugin.
2) You should never nofollow a home link from your post.(If there is more than one home from your post, then you could nofollow all but one). i can make a post on this…
I have the Platinum SEO plugin installed on my new blog. But haven’t got the time to play with it. I’ll take a look.
Yeah, I agree. I found that in every WordPress update I’ll need to make changes on the links if I choose to modify the core scripts. However I also added an alternative using the plugin I mentioned above. This is what I do now.
The reason I nofollow my homepage is because I wanted to prioritize the rank for my individual posts.
Update: But remember that I also need to anticipate a drop of my homepage’s rank due to a significant drop of links pointing to my homepage.
Feel free to add a follow up post to the article. I’ll look forward to read the article
Replaced All in One SEO Plugin with Platinum due to more options offered.
Judging from the output some polishing is still needed and your post will have a part in it.
My policy is DoFollow versus comments links.
Hi Ted. Yes, I also use Platinum SEO for my other blog and it does have more options offered. As soon as Platinum is proven to provide extra benefits, I’m replacing the ol All in One
You know what, the first thing I saw when I click on your site is your template. Looks neat.
Sorry, but as a designer, I appreciate such beauty. And you have a nice post as well. Thanks for sharing.
Thanks, John. It’s just a modified Revolution Church theme
I see you think the same way about http://easybilling.com/blog/listen-then-act/ too
Thanks for the step by step tutorial Louis, this is very helpful.
I use “SEO Smart Links” but it looks like it does not apply the “nofollow” everywhere… I’ll check out this “Platinum SEO”… thx for the tip !!
Francesco´s last blog post..Fusione tra Party Poker ed Everest Poker
Using SEO Smart Links, you can check the “Add nofollow attribute” at the bottom of the settings page if this is what you’re looking for. Good luck!
Thanks a ton mate. My site now is totally nofollow. You guys just rock
.-= Tech Frog´s last blog ..Blogs or Articles – Which one do search engines prefer? =-.
Hi Tech Frog,
glad to know that this short tutorial helps people. However, a couple of months earlier, news about Page Rank sculpting using nofollow is no longer recommended to spend most of SEO efforts on.
A lot of nofollow usage in a page may trigger Google’s suspicion and decrease a site’s rank.
This way, I’m inclined to suggest to delete links that are less important than giving them nofollow attribute.
Excellent post but unfortunately doesn’t answer to my question, how to add rel=”nofollow” to all sidebar links in wordpress? Any help?
Thanks a lot!
what links are on your sidebar? links going out or to your own pages? Since there are various kinds of links, you may need to add the nofollow manually or use the NAVT plugin: http://wordpress.org/extend/plugins/wordpress-navigation-list-plugin-navt/
Louis, you’ve done a wonderfull job here with this php snippets.
Still I’m looking to make no-follow only the wordpress sidebar links, which are generated by some plugins (most readed articles, top commented articles,etc).
Do you know any way to accomplish this? Though I’m not mastering php, so the solution should be a easy one
Thanks!
I see.. for plugin generated links you mentioned, since the links are pointing to pages inside your own blog you’ll need to modify the plugins themselves
you can do this via “Plugin | Editor”. Look for the lines with “a href” and add ” rel=”nofollow” ” after the “a” tag.
Do it one “a” at a time, then refresh your page to see if it has any effects. If not, restore the change you made and look for another “a href” to add another ” rel=”nofollow” “.
You’re suggested to make a backup for the plugin by copy-pasting the script to notepad FIRST and save it to your hard drive before making changes.
And if I may suggest, inbound links you mentioned above are just okay in my opinion. It’s ok to have them dofollow as they are
But the main question still remain unanswered. Should we add nofollow to all author links or not?
I guess yes.
It depends. But for whatever reason, I’ll leave them followed since excessive use of “nofollow” may alarm Google.
Thank you very much Great post…thanks for share this. ..
does anybody know the date seonetlinks is coming out? i heard it’s an amazing way to generate tons of traffic