Copied to clipboard

Flag this post as spam?

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


  • blackhawk 313 posts 1368 karma points
    Dec 09, 2017 @ 11:42
    blackhawk
    0

    Ability to remove last trailing slash from URL

    I'm on Umbraco 7.7.2 with Models Builder, and working on ways to reduce duplicate content. I would prefer the route of using canonical links to remedy this. I put together a little razor logic to produce the link...

      @{
         var node = Umbraco.TypedContent(@Model.Id);
         if (node != null)
         {
           string path = node.UrlAbsolute();
           <link rel="canonical" href="@path" />
          }
        }
    

    ...but would like to remove the trailing slash at the end of the URL value.

    Is this possible with this code?

  • Paul Wright (suedeapple) 277 posts 704 karma points
    Dec 09, 2017 @ 14:08
    Paul Wright (suedeapple)
    101

    Would this not suffice? umbracoSettings.config

      <!-- this will add a trailing slash (/) to urls when in directory url mode -->
        <addTrailingSlash>false</addTrailingSlash>
    
  • blackhawk 313 posts 1368 karma points
    Dec 11, 2017 @ 14:55
    blackhawk
    0

    That worked. My apologies for overlooking the setting for that!

Please Sign in or register to post replies

Write your reply to:

Draft