How to Nofollow Drupal Comments

Tags:

This is a quick hack to Drupal 5 to add rel=nofollow to the comment authors' homepages. I'm not recommending adding nofollow to comments, only describing the technique for people who are looking for it.

Generally it isn't a good idea to modify Drupal core code, but this method works.

Open /includes/theme.inc.

Change line 1052 from:
$output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));

to:

$output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.'), 'rel' => t('nofollow')));

And change line 1064 from:

$output = l($object->name, $object->homepage);

to:

$output = l($object->name, $object->homepage, array('rel' => t('nofollow')));

Technique originally described here.

Comments

Hacking the core ? Lots of

Hacking the core ?
Lots of time I was told "Don't hack the core !"
Don't you agree?

Webmaster Tips's picture

hacking the Drupal core

It's not good to hack the Drupal core, but if you need a quick and easy fix to nofollow your comments, this will work.

I used that method on this site because I'm experimenting with nofollow all over the site as an SEO experiment.

I think they are fixing this problem in future versions so that you can enable nofollow from the admin screen.

I would like to do something simialar in Drupal 6

Hi,

Could you tell me the best way for doing this in Drupal 6 and also how you can no follow links within comments?

I have found this example:
http://www.kinetasystems.com/blog/three-tips-for-comment-theming-in-drupal

But it doesn't seem to work for comments links but I can see you have overcome this.

Any advice would be great.

Thanks

Joey

Syndicate content