仅在主页上添加META关键字和说明

时间:2014-06-27 09:43:26

标签: ruby-on-rails

我想输入我的ruby网站的主页的关键字和说明。 主页有2个文件:

1- main_controller
2- home_page.html.erb


<% content_for :html_title, 'Erratum HUmanum Est' %>
<div class="clear"></div>
<div id="video">
  <div class="container">
        <div class="video-glow">
          <h1><%= t('application.home_page.heading')%></h1>
            <div class="clear"></div>
            <div class="video-section">
                <iframe width="418" height="235" src="https://www.youtube.com/embed/sfsfsfsfsfsfQ?rel=0;hd=1" frameborder="0" allowfullscreen></iframe>
            </div>
        </div>
    </div>
</div>

如何在这些页面上输入元描述和关键字? (我不想为此输入任何新的红宝石宝石) 谢谢, 罗马

1 个答案:

答案 0 :(得分:6)

application.html.erb添加类似内容;

<meta name="description" content="<%= yield(:description) %>" />
<meta name="keywords" content="<%= yield(:keywords) %>" />

然后在home_page.html.erb添加类似的内容;

<%= provide(:description, 'I would like to enter keywords and a description of the home page only of my ruby website. The home page has ') %>  
<%= provide(:keywords, 'Home, fred, grace, heaven, george') %>  

当你没有传递任何东西时,它将保持为空,没有meta_tags。