Sitecore Box

Sitecore web developer at Americaneagle.com

Hide Folder Item Name From URL in Sitecore




In this blog I will explain how we can exclude an item name from the URL programmatically. This can be done by using the out of the box alias feature in Sitecore, so when you create a new item under a specific path, an alias will be created for that item excluding the item you want to hide.


Aliases are based on the System/Alias template and defined under /sitecore/system/Aliases. Each alias name must be unique; the alias template contains a single field in the data section which allows for selection of the target item.

Sitecore determines the default URL for an item based on its path, for example, the URL for /sitecore/content/home/products/product1 is products/product1. Sometimes you need to have a shorter URL which maps to another URL, for example, accessing the above link by this URL /product1; and this what I am going walk you through in this blog.




What we need to do is adding an event on "item:created" to create a new alias whenever we create a new item under “Products” folder as you see in the below screenshot:




Below is the event handler for "item:created":


We need to create a new config file and add it the App_config folder: