现在的位置: 首页 > 综合 > 正文

Umbraco的Meta标记设置方法

2013年01月30日 ⁄ 综合 ⁄ 共 1110字 ⁄ 字号 评论关闭

http://www.farmcode.org/post/2009/06/17/Meta-tags-and-Umbraco.aspx

 

 

You’d think that you could do something like this to get meta description and keywords from umbraco

 <meta name="description" content="<umbraco:Item runat='server' field='PageDescription'/>" />

 

Unfortunately umbraco will render this:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><meta name="description" content="&lt;umbraco:Item runat='server' field='PageDescription'/>" /> 

 

The solution is inline xslt:

<umbraco:Item ID="Item" Field="PageDescription" runat="server"Xslt="concat('<meta name=&quot;description&quot; content=&quot;',{0},'&quot;/>')" XsltDisableEscaping="true"></umbraco:Item>

 

 

Or you could use the insert before and insert after possibilites when inserting fields like this 

<umbraco:Item field="siteDescription" insertTextBefore="&lt;meta name=&quot;keywords&quot; content=&quot;" insertTextAfter="&quot; /&gt;" runat="server"></umbraco:Item> 

This will be automatically generated for you, if you use the Insert Field button when editing the template and type in the start and end of the tag in the Insert before and Insert after fields. Saving you from having to type all the escaped characters yourself. 

抱歉!评论已关闭.