Opening a new window for comment links
OK, so today is my “tinkering” day. I finally got around to adding the “No Follow” functionality Moveable Type provides to help thwart comment spammers. (For those unfamiliar, it doesn’t stop the spammers, it just eliminates any benefit they get by telling search engines not to up their rank just because I’m inadvertantly linking to them.)
What the plugin does is analyze every link in comments and trackback pings and add “rel=’nofollow’” to them. I’ve taken it a step further and added “target=’_blank’” so that the user also gets a new window when they click comment links, which has been bugging me since I installed MT.
So how does it work? Well, in nofollow.pl, add the following line to the nofollowfy() function:
if ($rel) {
$rel =~ s/^(rels*=s*['"]?)/$1nofollow /i;
} else {
$rel = 'rel="nofollow"';
}
$rel = $rel.' target="_blank"';
@attr = grep { !/^rels*=/i } @attr;
'<a ' . (join ' ', @attr) . ' ' . $rel . '>';
The rest of the plugin does all the work, so it’s that simple.
Technorati tags: MT | MT Plugins | Moveable Type | nofollow | Web Development
