How to Name Items in Sitecore CMS

November 25, 2014

Blog | Development | How to Name Items in Sitecore CMS
How to Name Items in Sitecore CMS

This is the tenth in a series of posts about learning how to use and develop for Sitecore CMS; it is the follow-up post to “How to View Standard Fields in Sitecore CMS”. In this “How to” post I will be covering how to name items in Sitecore CMS, along with configuring naming restrictions, what the “Display Name” is, and how to use it.

An Item by Any Other Name

When Sitecore items are created, the content editor is asked to provide a name for the newly created item. The name chosen will be used as part of the URL of the item when viewing it as a webpage. The URL path will be the part of the Item Path after the site’s home item.

For instance, if an example site (http://example.com) has its home item at /sitecore/Content/Example, and has an item at /sitecore/Content/Example/about-us, the URL to the about-us item will be http://example.com/about-us.

This also means that special characters in an item name will need to be escaped when viewing the item. Spaces in item names will be converted to %20 when used in a URL. If the item from the previous example were named About Us, the apth to the page would be http://example.com/About%20Us. This negatively affects readability and SEO, so make sure you add the - between words to follow best practices.

Sitecore item names do not need to be unique, as items are always uniquely identified by their Item ID, which is a GUID. That said, having multiple items with the same name should be avoided because it makes the URL paths to the items ambiguous. Additionally, TDS expects items to be uniquely named, and will not be able to sync duplicate items properly.

Friendly URLs

When creating items that represent webpages, it’s important to craft the URL so that it’s friendly to end users, as user experience affects SEO ranking. URLs such as http://example.com/My%20Very%20Long%20Item%20Name are difficult to read, and should be avoided. One way to make life easier for users is to “dasherize” or “slugify” the item’s name.

In it’s simplest form, “dasherizing” is replacing spaces in the item name with hyphens. Other special characters should be removed as well to avoid percent encoded tokens like %20, %22, and %26, which are space , quote ", and ampersand & respectively.

To make life easier for the content editor, “dasherizing” can be applied automatically when Sitecore items are created or renamed. This topic will be covered in-depth in a future blog post.

Renaming Items

Item renaming is very simple in Sitecore. Because it’s so easy to rename items in Sitecore, referencing items by name in code is strongly discouraged. Code that needs to reference specific items should do so via ID, or make use of intermediary link fields.

Items can be renamed in the content editor in three different ways.

From the Ribbon

Select the item you’d like to rename in the content tree. On the “Home” tab of the ribbon, click the “Rename” button in the “Rename” section.

Sitecore 8 ribbon showing the Rename button on the Home tab
Sitecore 8 ribbon showing the Rename button on the Home tab
Sitecore 6 & 7 ribbon showing the Rename button on the Home tab
Sitecore 6 & 7 ribbon showing the Rename button on the Home tab

A simple prompt will open asking for the new name for the item.

Sitecore 8 showing the Rename modal
Sitecore 8 showing the Rename modal
Sitecore 6 & 7 showing the Rename modal
Sitecore 6 & 7 showing the Rename modal

Change the name for the item and click “OK” when finished.

From the Item

Select the item you’d like to rename in the content editor. Click on the item’s name above the list of field groups.

Sitecore 8 showing the editable name in the content editor
Sitecore 8 showing the editable name in the content editor
Sitecore 6 & 7 showing the editable name in the content editor
Sitecore 6 & 7 showing the editable name in the content editor

A simple prompt will open asking for the new name for the item.

Sitecore 8 showing the Rename modal
Sitecore 8 showing the Rename modal
Sitecore 6 & 7 showing the Rename modal
Sitecore 6 & 7 showing the Rename modal

Change the name for the item and click “OK” when finished.

From the Item’s Context Menu

Right-clicking on the item you’d like to rename in the content tree will open a context menu. Click on the “Rename” item in the context menu.

Sitecore 8 showing the item context menu
Sitecore 8 showing the item context menu
Sitecore 6 & 7 showing the item context menu
Sitecore 6 & 7 showing the item context menu

A simple prompt will open asking for the new name for the item.

Sitecore 8 showing the Rename modal
Sitecore 8 showing the Rename modal
Sitecore 6 & 7 showing the Rename modal
Sitecore 6 & 7 showing the Rename modal

Change the name for the item and click “OK” when finished.


A Note on Naming Restrictions

By default, Sitecore restricts what characters can be used when naming an item. The following characters are blacklisted by default: (space), /, :, ?, ", <, >, |, [, and ]. This setting can be changed in the project’s web.config file by modifying:

<setting name="InvalidItemNameChars" value="\/:?&quot;&lt;&gt;|[]"/>

Display Name

When viewing items in Sitecore, it would be nice to still be able to se the original non-dasherized item names. On multilingual sites, it’d be helpful to be able to see the translated item names.

This is where the “Display Name” comes in. An item’s display name will override the name shown in the content editor. The item’s name will still remain, so linking to the item can still use the dasherized path.

Display Name is a field in standard fields, so it supports assigning different display names for different languages.

An item’s display name can be changed in two different ways.

From the Ribbon

Select the item you’d like to change. On the “Home” tab of the ribbon, click the “Display Name” button in the “Rename” section.

Sitecore 8 showing the Display Name button in the ribbon
Sitecore 8 showing the Display Name button in the ribbon
Sitecore 6 & 7 showing the Display Name button in the ribbon
Sitecore 6 & 7 showing the Display Name button in the ribbon

A simple prompt will open asking for the new display name for the item.

Sitecore 8 showing the Display Name modal
Sitecore 8 showing the Display Name modal
Sitecore 6 & 7 showing the Display Name modal
Sitecore 6 & 7 showing the Display Name modal

Change the display name for the item and click “OK” when finished.

From the Display Name Field

Select the item you’d like to change. Show standard fields if they’re not already visible. Open the “Appearance” field group. Update the text in the “Display name” field, and save the item when finished.

Sitecore 8 showing the Display Name field
Sitecore 8 showing the Display Name field
Sitecore 6 & 7 showing the Display Name field
Sitecore 6 & 7 showing the Display Name field

A Note on Display Name

Once an item’s display name has been changed, Sitecore will show the display name in the content editor anywhere the item is listed, which includes the content tree, link fields, tree lists, and so forth.

Selecting an item will show the display name as the primary header, with the actual name following it in square brackets:

Sitecore 8 showing an example display name
Sitecore 8 showing an example display name
Sitecore 6 & 7 showing an example display name
Sitecore 6 & 7 showing an example display name

Clicking on the item’s Display name - [Name] will still only modify the item’s name.


Up next: “How to Delete Items in Sitecore CMS”

Tim Leverett

Senior Developer
Tags
  • Content Management
  • Sitecore
Sitecore Survival Guide Volume 1

If you found this post helpful, there are plenty more where it came from! You'll find the first 10 here.

Download the first 10 posts in our Sitecore how-to series by Developer Tim Leverett!

Recent Work

Check out what else we've been working on