How To Add Nofollow to the Wordpress Comments Link

July 5th, 2008 by Mack

I actually had a damn hard time finding this posted anywhere on the web, so I thought I would share.  I don't think I need to tell anyone why this is a good idea, but it is basically eliminating search engines from indexing useless links. We will use the following as an example.

Useless Links For Search Engines (possibly dup content)

http://www.lobolinks.com/blog/which-search-engine-had-the-best-4th-of-july-display/#respond

http://www.lobolinks.com/blog/entrecard-suggestions/#comments

I think you see my point.

How To Instructions

Open wp-includes/comment-template.php

Find (was around line 763 for me)

PHP:
  1. echo ' title="' . sprintf( __('Comment on %s'), $title ) . '">';

Change To

PHP:
  1. echo ' title="' . sprintf( __('Comment on %s'), $title ) . '" rel="nofollow">';

Save and Upload.  Your done.

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • del.icio.us
  • StumbleUpon
  • Sphinn
  • Mixx
  • Reddit
  • Technorati

Related Post

4 Responses

  1. By Squeaky on Jul 6, 2008 | Reply

    Thanks for the very useful code. I think this will work rather well, but if I would ever decide to let registered users post have the follow tag on their comments, then it would be an issue to address.

    Since I am rather new to blogging, not sure if it is important to allow a follow tag on registered users comments, if it is something to consider?

  2. By Mack on Jul 6, 2008 | Reply

    Squeaky, their are lots of dofollow plugins for Wordpress that will allow you to control what is followed.

    http://kimmo.suominen.com/sw/dofollow/

    Even if you have one of the dofollow plugins it shouldn't conflict with this hack.

  3. By Dennis Edell on Jul 8, 2008 | Reply

    I'm a little confused. On the links you gave, are you referring to the duplicate "related posts" entries?

  4. By Mack on Jul 8, 2008 | Reply

    Well lets compare the urls, this is the normal permalink.
    http://www.lobolinks.com/blog/how-to-add-nofollow-to-the-wordpress-comments-link
    This is the one to jump straight to comments.
    http://www.lobolinks.com/blog/how-to-add-nofollow-to-the-wordpress-comments-link/#comments
    The problem is, search engines will see that as two different urls. So, we need to eliminate one of them with nofollow. We would all like to think the "bots" are smart enough to know the difference, but probably not.

Leave a Reply