Blog

Nice little tips to organise your Umbraco Page URLs

Umbraco URL

Here are some tips and tricks you can use for Umbraco CMS related developments. You will be able to use the following techniques to organise your Umbraco page URLs.

NiceUrl

This is the most common way for us to return a "Friendly URL" for a given node in the Umbraco content section. As explained in Umbraco, a 'Friendly URL' is the complete encoded URL excluding the domain. But this depends on the settings you configure in UmbracoSettings.config file. If you set useDomainPrefixes=true in UmbracoSettings.config, NiceUrl returns the url including the domain.

NiceUrl with XSLT:

This will return current page URL;

This will return hyperlink to parent page;

NiceUrl with Razor:

This will return current page URL;

This will return hyperlink to parent page;

Model is basically Razors equivalent of "$currentPage" in XSLT.

NiceUrl with C#:

This will get the current page URL to a string; 

This will get the parent page URL to a string;

 

NiceUrlFullPath

This is exactly the same as above NiceUrl method mentioned above, except it returns the full url with a domain for a given node in the Umbraco content section.

This will return current page URL with the domain name;

Please note this method was obsoleted in Umbraco 4.10.0+.

 

umbracoUrlName

When you create umbracoUrlName alias with a text-string property, it allows you to change the URL of the node without changing the name of the node/page you have created.

For example, in the News section we have a page called "News and views around the world" which creates the following URL by default.

http://localhost/news/news-and-views-around-the-world.aspx

If we were to enter "around-the-world" in the umbracoUrlName property, you will change the URL of the page to,

http://localhost/news/around-the-world.aspx

 

umbracoUrlAlias

As Umbraco explains, using the "umbracoUrlAlias" alias with a text-string property will enable you to provide multiple URLs for a content node.

For example if we were to enter "news,events/upcoming-events", this would resolve the following URLs to the same page.

/news.aspx
/events/upcoming-events.aspx

Things to note: you should always use umbracoUrlAlias field value in lowercase letters, not use a leading slash and not use a trailing ".aspx".

 

removeDoubleDashes setting

This settings can be used to remove double dashes from your page URL. This configuration setting can be found under UmbracoSettings.config file.

Under <urlReplacing>, the removeDoubleDashes attribute makes sure the double dashes will not appear in the url. Set it to false if you want to have double dashes.

 

urlReplacing setting

This is another setting that can be found inside UmbracoSettings.config file. You can find the list of characters which will be replaced in generated urls. This ensures that urls does not contain characters that search engines or browsers do not understand. Umbraco comes with a predefined set of characters and you can add your own as well.

Here is how you remove comma and brackets from your page URLs.

I hope these techniques will help someone.

 

Share this with

 

No comments have been posted yet. Please feel free to comment first!

 

Post a comment

Thank you! Your comment will be posted after it is approved.
Sorry! Something went wrong. Please try again.

 

 

 

Advertisement