Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • trfletch 595 posts 571 karma points
    Apr 12, 2010 @ 17:50
    trfletch
    0

    Meta description macro

    Hi, I have been trying to create an XSLT to show different meta descriptions depending on the page they are on. I have my XSLT how I want it but I can't work out how to make it show as the meta description. I tried the following in my master template:

    <meta name="description" content='<umbraco:Macro Alias="Meta-description" runat="server"></umbraco:Macro>' />

    but it just gave the following output on the page:

    <meta name="description" content="&lt;umbraco:Macro Alias=&quot;Meta-description&quot; runat=&quot;server&quot;>&lt;/umbraco:Macro>" />

    I then tried adding the following in my XSLT:

    <xsl:text>
    <meta name="description" content='
    </xsl:text>

    ***XSLT to get description***

    <xsl:text>
    ' />

    </xsl:text>

    But that did not work either, I even replaced the less than and greater than signs for their HTML equivalent. I did search the forum and found a post that seemed to match what I was trying to do but for some reason all the important bits (the code) was not visible? Not sure if there is an issue with the forum, the post was: http://our.umbraco.org/forum/developers/xslt/1462-meta-data

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Apr 12, 2010 @ 18:11
    Tom Fulton
    1

    Try this in your XSLT file:

     

    <meta name="description">
    <xsl:attribute name="content">
    *** XSLT to get description ****
    </xsl:attribute>
    </meta>
  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Apr 12, 2010 @ 18:27
    Jan Skovgaard
    0

    Hi

    I think you might be able to render the macro by writing it like this

    <meta name="<umbraco:Macro Alias="Meta-description" insertTextBefore="content=&quot;" insertTextAfter="&quot;" runat="server"></umbraco:Macro>" />

    Does it help?

    /Jan

  • Ove Andersen 435 posts 1541 karma points c-trib
    Apr 13, 2010 @ 10:09
    Ove Andersen
    1

    Do you have the meta description stored in the umbraco node? I.e. as a property for each page?

    If so, you can just use the umbraco item like this:

    <umbraco:Item field="metaDescription" insertTextBefore="&lt;meta name=&quot;description&quot; content=&quot;" insertTextAfter="&quot;/&gt;" runat="server"></umbraco:Item>
  • trfletch 595 posts 571 karma points
    Apr 13, 2010 @ 13:34
    trfletch
    0

    Hi Tom,

    Thanks that has worked perfectly.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies