Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I configured the Text Format "Plain text" (admin/config/content/formats) to "Convert URLs into links" so I would like to add the attribute rel="nofollow" to all the links in the comments.

This way I would minimize the effects of spammy links in the comments.

Is there an easier way than using regular expressions to insert the attribute?

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

Go to Configuration -> Content authoring -> Text formats -> Plain text (your format), then tick the Limit allowed HTML tags option.

In the filter settings at the bottom of the page is the Add rel="nofollow" to all links checkbox. Tick that... Since this is plain text, you will probably want to remove the contents of the Allowed HTML Tags field, too.

share|improve this answer
    
Oh my... that was easy. I should have seen that. –  FR6 Dec 23 '11 at 18:24
    
It's not in the most intuitive of places, I must say... –  Jim Kirkpatrick Dec 23 '11 at 18:26
    
very cool! I wasted about half an hour too looking at extlink and links_nofollow modules ;-) –  MotoTribe Dec 23 '11 at 23:28
    
It does not work but this one does: befused.com/drupal/nofollow . Unfortunately it adds nofollow to internal links too. Here is alternate way: thecarneyeffect.co.uk/… . Here is more about using nofollow with internal links: searchengineland.com/… –  AgA Dec 18 '13 at 10:00
add comment

Jim is mostly Right (but it matters what order the filters are in and you would need to add the <a> at least to that filter). A slightly better way (in that it lets users still put in just the URL or protects you if they try to all a rel=follow to their a tag) would be:

  1. Go to admin/config/content/formats/plain_text
  2. Check only Limit allowed HTML tags, Convert line breaks..., and Convert URLs into links.
  3. Make sure your filter is ordered starting with Convert URLs into links, then Limit allowed HTML tags, then Convert line breaks into HTML...
  4. Under Limit allowed HTML Tags filter settings, change allowed HTML to just <a> and make sure the Add rel="no-follow" to all links is checked. I like to unchecked the Display basic HTML help in long filter tips here.
share|improve this answer
add comment

noindex_external_links is a nice module to add rel=nofollow to external sites. We can dofollow selected sites and it does not add nofollow to internal links.

To make it work I placed the filters in this order(for plain text format): Display any HTML as plain text -> Content URL's into links -> Noindex external links filter

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.