Sitecore Aliases

Introduction

I wanted to write a technical analysis on how to use aliases out of the box functionality in Sitecore and how to add the ability to use multi-site aliases.

Aliases is a way to create very short urls for content,  some kind of shortcuts.

What we need to do

  • We need to have aliases for each site.
  • We need to configure the location where we’ll store aliases for each site.

Configuration in Sitecore

Instead of having our aliases stored under “/sitecore/system/Aliases” folder, we can define a folder for each site where we can put our aliases.

We’ll put Aliases folder under /sitecore/content/<Website>/<Config Container>/. Or we can have it more configurable by creating a configuration item to tell us from where we’ll pick up the aliases.

Under this aliases folder we can create subfolders where editors can group the aliases. We can let it  just free for editors to add folders there. This is useful if we’ll have a huge number of aliases.

For a specific item we can create an alias for it through this aliases sitecore user  interface(Content Editor -> Presentation Tab -> Aliases):

unnamed

Note

Having multiple URLs for an item can reduce Search Engine Optimization (SEO) value. However we can to avoid that by implementing a canonical URL in the head, to ask the search engine to index the real url instead for the aliases.

  • Editors should create aliases that have unique name.
  • Editors should not create aliases that have the same name as content at the first level of hierarchy.
  • Aliases generally do not improve performance, so editors should limit their use.

Technical

We need 2 things:

  • Modify the way how Sitecore is resolving the aliases by going to the aliases folder under each site.
  • Modify the way Sitecore is saving the aliases to point it to the specific folders.

Override AliasResolver

We can rewrite the Sitecore.Pipelines.HttpRequest.AliasResolver to create a processor and change the logic of getting the aliases and then go the target. In order to replace the processor in the httpRequestBegin pipeline, this is what we should do in Pressors.config:

<processor patch:instead=”processor[@type=’Sitecore.Pipelines.HttpRequest.AliasResolver, Sitecore.Kernel’]”
type=” <Your Namepace>.AliasesResolverProcessor, <Your DLL name>”/>

I will create another post for that to show possible strategies to deal with Aliases instead of Sitecore Database.Aliases out-of-the-box.

Creating aliases

We’ll create a dossier in the common project under Sitecore/shell/Applications/ContentManager/Dialogs/ where we’ll override some actions in the class Sitecore.Shell.Applications.ContentManager.Dialogs.Aliases.AliasesForm

In that class we need to create methods that we’ll need instead of the default actions: Add_Click , Remove_Click

For instance we need to modify a behavior like the default behavior. We should change this method and make it link to where we store our aliases for each site. I will create another post for that to go further in details.

We should also modify the dialog xml (sitecore\shell\Applications\Content Manager\Dialogs\Aliases\Aliases.xml) to take into account our action methods. We’ll override this xml is the same location our cs implementation class: Sitecore/shell/Applications/ContentManager/Dialogs/

<CodeBeside Type=”<Namespace>.AliasesForm,<Dll name>”/>

Configuring access to Aliases

In order to limit the use of Aliases, access rights can assist with that objective.

However if we’ll move the aliases folder and put it in each website, probably we’ll need to modify the access rights for the new personalized folders. For the default location under  “/sitecore/system/Aliases”, it is the role  “Analytics Maintaining” who can an navigate to this branch can read, create, update, and delete items.

The “/sitecore/content/Applications/Content Editor/Ribbons/Chunks/Page Urls” item in the Core database controls access to the URL group on the Presentation tab in the Content Editor and the Aliases command that it contains. Sitecore grants read access to this group definition item to the Analytics Maintaining, Sitecore Client Configuring, Sitecore Client Developing, and Sitecore Client Maintaining roles in the sitecore security domain. To allow users access to the Aliases command, we can add those users to one of these roles or update access rights to the “/sitecore/content/Applications/Content Editor/Ribbons/Chunks/Page Urls” item in the Core database.

If we want to really limit the use of aliases we need to allow the rights maybe per user and not per role.

— June 1, 2016

2 thoughts on “Sitecore Aliases

  1. It’s always a relief when someone with obvious exirtepse answers. Thanks!

What Do You Think?