Umbraco的Meta标记设置方法

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. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值