Rails rel nofollow link
Asked Answered
W

1

22

I need to create no follow links with link_to.

I'm looking for something like this:

<%= link_to "example", example_path, :target => "_blank" %>

But for no follow of course.

Wizardly answered 31/7, 2010 at 0:30 Comment(0)
D
44

You can specify other attribues with link_to:

<%= link_to "example", example_path, rel: 'nofollow' %>

Produces:

<a rel="nofollow" href="example_path">example</a>
Ddene answered 31/7, 2010 at 1:16 Comment(1)
NB that if you are passing in arguments then you may need something like extra braces: <%= link_to 'example', {:controller => :controller_name, :action => :ask, :param1 => "setting"}, :rel => 'nofollow' %>Warrantor

© 2022 - 2024 — McMap. All rights reserved.