Copied to clipboard

Flag this post as spam?

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


  • Shane 13 posts 96 karma points
    Dec 08, 2009 @ 16:33
    Shane
    1

    Add meta description and keywords???

    Hi All,

    I have just started using this tool for a new project. I can't seem to find a good way to add my meta data. I have created my page properties but can not find a way to bind them into my meta tags. I have tried:

    <meta name="keywords" Content="<umbraco:Item field='Keywords' runat='server'></umbraco:Item>" />

    What is the best practice way of doing this? Any suggestions would be welcome.

    Thanks,

    Shane

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Dec 08, 2009 @ 16:43
    Sebastiaan Janssen
    1

    Try it with the single/double quotes the other way around: 

    <meta name="keywords" Content='<umbraco:Item field="Keywords" runat="server"></umbraco:Item>' />

     

    Other than that, I would add: recursive="true" so that you don't have to fill in the meta info on every page, If recursive is on, it will look at the parent for existing meta info and if the parent doesn't have anything, it looks in the grandparent, and up, all the way to the highest node in the tree.

  • Shane 13 posts 96 karma points
    Dec 08, 2009 @ 16:51
    Shane
    0

    Hi Sebastiaan,

    Thanks for the reply. I still get the same problem though, my source comes out like this:

    <meta name="keywords" content="&lt;umbraco:Item field=&quot;Keywords&quot; runat=&quot;server&quot;>&lt;/umbraco:Item>" />
  • Chad Rosenthal 272 posts 474 karma points
    Dec 08, 2009 @ 18:40
    Chad Rosenthal
    0

    Can you post the original line of code? I just used the following code:

    <meta name="description" content='<umbraco:Item field="metaDescription" recursive="true" runat="server" />'> <meta name="keywords" content='<umbraco:Item field="metaKeywords" recursive="true" runat="server" />'>

    And it worked. Try change the double quotes after content= to a single quote.

  • Lee 1130 posts 3088 karma points
    Dec 08, 2009 @ 20:33
    Lee
    0

    Mine works fine like this

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

    Do you have runat="server" on your head tag?  

  • Petr Snobelt 923 posts 1535 karma points
    Dec 08, 2009 @ 21:22
  • Shane 13 posts 96 karma points
    Dec 09, 2009 @ 11:46
    Shane
    0

    Thanks for the help guys, I can't explain why it wasn't working.

    Petr, your solution did the trick!Thanks a lot.

  • Robert 9 posts 29 karma points
    Jan 19, 2010 @ 13:08
    Robert
    0

    I don't get the Richard Soeteman thing... my tags remain empty.

  • Robert 9 posts 29 karma points
    Jan 19, 2010 @ 13:58
    Robert
    0

    I've sorted it out.

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Jan 22, 2010 @ 02:59
    Chris Houston
    0

    Hi,

    In case anyone else has this problem, I always use the same XSLT Macro for adding my meta tags and I have just uploaded it.

    Meta Tags for Umbraco

    It is a very simple macro, so don't expect rocket science :)

    Cheers,

    Chris

  • kashif 18 posts 38 karma points
    Nov 16, 2010 @ 09:18
    kashif
    0

    Chris , your link is dead. Could you please update it.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Nov 16, 2010 @ 09:27
  • Johan Plate 3 posts 23 karma points
    Feb 08, 2011 @ 14:29
    Johan Plate
    0

    It wont work with runat="server" at the head-tag.

     

    Use this instead.

    <umbraco:Item field='metaKeywords' insertTextBefore="<meta http-equiv='keywords' content='" insertTextAfter="' />" runat='server'></umbraco:Item>

    When you have the runat="server"in the head tag.

     

     

  • Yannick Smits 321 posts 718 karma points
    Mar 29, 2011 @ 17:22
    Yannick Smits
    1

    Or in Razor you can now do:

          <umbraco:Macro language="cshtml" runat="server">
            <meta name="keywords" content="@Model.AncestorsOrSelf().Where("metaKeywords !string.Empty").Last().metaKeywords" />
            <meta name="description" content="@Model.AncestorsOrSelf().Where("metaDescription !string.Empty").Last().metaDescription" />
          <umbraco:Macro>

    even in a runat=server head.

Please Sign in or register to post replies

Write your reply to:

Draft