2014-06-27 35 views
0

我想輸入關鍵字和我的紅寶石網站的主頁說明。 主頁有2個文件:僅在首頁添加META關鍵字和描述

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> 

我怎麼能進入這些頁面上的meta描述和關鍵字? (我並不想進入這個任何新的紅寶石寶石) 謝謝, 羅馬

回答

2

在你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。

+0

非常感謝。你確認這隻會影響主頁,而不會影響網站的其他頁面? – Roman

+0

它只顯示您提供數據的位置。如果它適合你,然後將其標記爲答案。 – Acacia

+0

@羅曼,它有效嗎? – Acacia