Meta tags and Umbraco

by AnthonyDang 17. June 2009 12:01

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>

 

 

Tags:
Categories: .Net | Umbraco

Comments

6/17/2009 1:22:42 PM #

Hello Anthony,
Your first code snippet should work as I have used it before without any problems.

What datatype is the PageDescription property set to?

Personally I use the Textbox multiple.

Hope that helps you.
Warren :)

Warren Buckley United Kingdom

6/17/2009 1:32:43 PM #

Textstring was the type in question.

AnthonyDang Australia

6/17/2009 7:06:19 PM #

I've also never been able to get that to work, always had to resort to Anthony's implementation.

Shannon Deminick Australia

6/25/2009 6:04:30 PM #

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.

Regards
Jesper Hauge

Jesper Hauge Denmark

6/18/2010 1:28:39 PM #

An excellent presentation. Clear. Practical. Insightful. Shows a depth of experience. Thank you. I learned a great deal.

mahabaleshwar hotels India

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading