簡體   English   中英

<a>Rails 3 erb文件中的</a> rel屬性

[英]rel attribute in <a> in Rails 3 erb file

我想知道在<%= link_to_peramlink%>中有任何rel屬性,就像html中的tag一樣。

例如:在html我的鏈接

我在rails中有<%= link_to_permalink文章,“con”,nil,“my link”,“5m”%>。 那里有任何rel屬性嗎?

link_to_permalink不是標准的Rails助手。 一個簡單的:

<%= link_to article.title, article %>

(您可能必須調整article.title )將讓你的文章鏈接,假設是這樣resources :articles中定義routes.rb

設置rel屬性很簡單:

<%= link_to article.title, article, :rel => 'nofollow' %>

或其他屬性:

<%= link_to article.title, article, :rel => 'nofollow', :class => 'my-css-class' %>

最后,我不知道你的link_to_permalink助手做了什么,但你可以使用to_param來制作seo友好的永久鏈接: 見這里 (如果您知道我的意思,這就是“鐵路方式”。)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM