Copied to clipboard

Flag this post as spam?

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


  • Hannes 28 posts 189 karma points
    Jul 06, 2023 @ 15:53
    Hannes
    0

    Umbraco node url format (slash to dash)

    Hi,

    I recently upgrade an Umbraco 7 site to Umbraco 10. I now find that the Url link format for some nodes has changed. Nodes that previously had a slash as part of their node name would have a dash in the Url link. In Umbraco 10 this has now changed and the dash was removed. E.g.:

    Umbraco 7 behaviour: Orchestra/Band Conductor -> /orchestra-band-conductor/

    Umbraco 10 behaviour: Orchestra/Band Conductor -> /orchestraband-conductor/

    Does anybody know if the node Url link format behaviour can be customized via an extension method maybe or a setting somewhere?

    Thanks, Hannes

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Jul 06, 2023 @ 16:56
    Marc Goodson
    100

    Hi Hannes

    You can control how Umbraco builds the segments for the Urls generated for the content by using a custom UrlSegmentProvider (or custom UrlProvider).

    There is a reasonably good introduction to the concept here:

    https://docs.umbraco.com/umbraco-cms/reference/routing/request-pipeline/outbound-pipeline#custom-url-provider

    A lot depends though on whether you 'prefer' the new V10 default rule to replace slashes with dashes, and just want to make sure the old URLs 301 redirect to the new URL- or if or are keen to maintain the slashes being completely removed...

    The custom UrlSegmentProvider or UrlContentProvider is only 'one half' of the problem, these just control the rules that defines what the Url should be, eg what you see in the backoffice, and if in code you write out Model.Url() to render a link, it controls what will be rendered...

    ... the second half of the customisation is to map the incoming Url to the content ...

    This would be achieved by creating a Custom IContentFinder...

    https://docs.umbraco.com/umbraco-cms/reference/routing/request-pipeline/icontentfinder

    The ContentFinders job is to take the incoming url, and either map it to the content item in Umbraco (based on whatever logic you decide) or it could issue a redirect to a different Url (hence it depending on whether you want the dashes or not, eg if you just do a redirect, then you don't need a custom UrlSegment provider!)

    Anyway hopefully these two articles give you an introduction of how you can modify the 'outgoing' Umbraco Pipeline, that generates the expected Url and the 'incoming' Umbraco Pipeline that maps the incoming Umbraco Url to the content...

    regards

    Marc

  • Hannes 28 posts 189 karma points
    Jul 06, 2023 @ 17:02
    Hannes
    0

    Thanks a lot Marc. Much appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft