Links rel=”nofollow” for SEO

nofollow for seo

Page Rank Sculpting

Not too long ago we were able to control the flow of page rank throughout our site, sort of. I don’t plan on explaining page rank here, if you need a refresher go to the source. I am working on a links page that will pass solid page rank and not just a normal links page that doesn’t have any power.

Then, I ran into a problem from the past.

Google helped introduce the NOFOLLOW attribute mainly because of blog spam and now WordPress uses this attribute on most every link in your blog that is created.

Removing nofollow from WordPress Bookmarks

While having rel=”nofollow” on my comments is a great idea, I would like to remove this from the links that are created on the blogroll. Obviously I can manually create all the links on my new links page, but what if I create a WordPress theme and want people to be able to add links easily? WordPress already has a feature for bookmarks; so I should try to use their system if I can and save coding time.

Using a WordPress function

When I created my links page I used the wp_list_bookmarks() template tag to get my list of links. I first thought that I would need to pass some sort of command through this template tag on my links page, but after some research I found a very easy solution using my functions.php file; just add this code:

function nofollow_my_bookmarks( $links ) {
    foreach($links as $link) {
        $link->link_rel = '';
    }
    return $links;
}
add_filter('get_bookmarks', 'nofollow_my_bookmarks');

Code Explained

Basically there are only two steps here; first you create the function that will replace the code in the links attributes (removing the nofollow) and second you add your filter to the get_bookmarks WordPress hook.

  1. function – is what creates the function
  2. nofollow_my_bookmarks – is the name of the function
  3. $links – is the variable that will contain the data from the get_bookmarks hook
  4. foreach – will run through each link in the content ($links)
  5. $links as $link – will create the $link variable for each link in the content so we can change the attributes
  6. $link -> link_rel = ‘ ‘ – this will run for each link and look for the REL attribute. Once found it will replace it with ‘ ‘ or nothing
  7. return $links – this sends the new data back to WordPress with rel=’ ‘ instead of anything that was in the rel already
  8. add_filter() – with this we are hooking into WordPress
  9. get_bookmarks() – this is the WordPress hook we are looking for that lists all the links from your blogroll
  10. nofollow_my_bookmarks – here we call the our function name so that this function will be called each time someone uses the wp_list_bookmarks() template tag
Conclusion

If you run this function ‘as is’ then you will REMOVE all code in your REL attribute for links

I am starting my site from scratch and I have no plugins adding code to my links; so this is not a problem for me. This could be a problem for you, just check your source code on your blog roll to check your rel attribute settings.

By changing the function a little you could add your own code or search for “nofollow” and remove just that text…Be creative :~D

About Jim Gaudet

An IT guy relaxing in Costa Rica
This entry was posted in Web Design, Wordpress. Bookmark the permalink.

2 Responses to Links rel=”nofollow” for SEO

  1. Jom Adastico says:

    I will be starting my own site in a couple of days, let me check if this works for me. I think this will be a great idea to implement – im passing it to my friends too. Keep us posted with additional information.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>