Copied to clipboard

Flag this post as spam?

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

  • MB 108 posts 397 karma points
    Jan 11, 2021 @ 04:53

    API to generate URL-Slug from Node-Name

    For various reasons, I need to save the URL-Slug for a new node, as the node is being saved, in a separate area, and need to ensure the same rules are applied for sanitizing it, so that it exactly matches the URL-Slug generated by Umbraco when saving the node.

    I assume there is a callable API function to process the node-name to a URL-Slug - i.e. the Umbraco 'Slugify' utility - but finding it is another story.


  • Marc Goodson 1733 posts 11490 karma points MVP 7x c-trib
    Jan 11, 2021 @ 08:34
    Marc Goodson

    Hi MB

    There is an Extension method called ToUrlSegment()

    In the Umbraco.Core namespace

    So if you have the string representation of the name of the node that you are creating, the url slug should be just the result of calling ToUrlSegment() on it



  • MB 108 posts 397 karma points
    Jan 11, 2021 @ 08:54

    Excellent - exactly what I needed.

    I read the code, and it has it's own way of handling UTF8 - finding definitive rules on this and diacritic handling is a real can of worms - but so long as I'm doing it the 'Umbraco' way, that's all that matters to me.


Please Sign in or register to post replies

Write your reply to: