I know I can pass :rel => "nofollow"
to link_to
but is there a way to set that by default so I don't have to make changes in each link_to
tag?
Asked
Active
Viewed 1,025 times
8
2 Answers
19
In your application helper you can override the link_to
method and replace with your own.
def link_to(name, options = {}, html_options = {})
html_options.merge!(:rel => :nofollow)
super(name, options, html_options)
end

Abel
- 56,041
- 24
- 146
- 247

Jesse Wolgamott
- 40,197
- 4
- 83
- 109
-
In case you don't want to overwrite any `rel` values already on your link, try using `merge_nicely!` instead: https://gist.github.com/joshuapinter/78a5545d713ab9d55883 – Joshua Pinter Sep 21 '14 at 05:01