Copied to clipboard

Flag this post as spam?

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


  • milkman matty 19 posts 100 karma points
    Jul 18, 2018 @ 23:46
    milkman matty
    0

    Getting a Node Slug

    Hi community,

    I feel like this is a silly question but I can't figure out the way to get just the slug for a node. Is there even a built in way to do this? Currently I am using the following which seems less than bulletproof:

    @node.Name.ToLower().Replace(" ","-").Replace("&","")
    

    If the case calls for it I might change the Replace call to a Regex Replace to catch more. The only other alternative I can think of is getting the node's URL, splitting on '/' and grabbing the last element.

    Is there a way to get the just a node's slug in umbraco?

  • August 7 posts 117 karma points
    Jul 19, 2018 @ 01:12
    August
    100

    Use

    @node.UrlName
    
  • milkman matty 19 posts 100 karma points
    Aug 02, 2018 @ 00:22
    milkman matty
    0

    That's exactly what I needed! For the life of me I couldn't find that method call. Thanks for the info!

  • 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