2014-11-21 50 views
1

我正在嘗試使用下面的代碼來生成我的meta描述標籤如何在Jekyll中使用strip_html進行元描述時刪除降價?

<meta name="description" content="{{ page.content | strip_html | truncatewords: 50 }}"> 

但是這是什麼顯示

##Sending Several Documents to a Group## Using online storage accounts like [Dropbox](http://dropbox.com) 

是有辦法也剝奪降價標籤?

回答

10

你可以做:

<meta name="description" 
content="{{ page.content | markdownify | strip_html | truncatewords: 50 }}"> 

但它只會與md/markdown文件,而不是HTML工作。這不會產生Liquid tags

該解決方案可以設置在頁面/後前事項的description: foo bar,並把它在_includes/head.html有:

{% if page.description %} 
    <meta name="description" content="{{ page.description }}"> 
{% else %} 
    <meta name="description" content="{{ site.description }}"> 
{% endif %} 
+0

感謝,完美的工作 – w1n78 2014-11-21 21:37:29