Mike Skutta Blog

Sitecore How-To: Programmatically Create Friendly Field Titles

Alex Pershteyn and Mike Skutta


This is an article in a series of Sitecore how-to articles. These articles are meant to be quick guides to accomplish various tasks within Sitecore. The how-to articles have proven to be very helpful internally at One North Interactive https://www.onenorth.com. These articles assume working Sitecore knowledge. I just wanted to share the articles with the community. Hopefully you find them helpful.


Here’s a script to create friendly field titles in Sitecore. It will convert all field names in Camel Case and Lower Camel Case format. You need to provide guid of the top-level node under Templates and it would recursively go through every template and update field names as needed.

Step-by-step guide


<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="Sitecore.Data" %>
<%@ Import Namespace="Sitecore.Data.Items" %>
<script runat="server">
    Guid templateFieldID = new Guid("{455A3E98-A627-4B40-8035-E683A0331AC7}");
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
    void UpdateFriendlyTitles_Click(object sender, EventArgs e)
        var rootItemId = new ID(new Guid(RootItemId.Text));
        var item = Database.GetDatabase("master").GetItem(rootItemId);
        if (item == null)
            throw new ApplicationException(string.Format("Cannot find item with id {0}", RootItemId.Text));

    private void AddFriendlyFieldTitles(Item currentItem)
        if (!currentItem.HasChildren)

        foreach (Item child in currentItem.Children)
            if (child.TemplateID.ToGuid() == templateFieldID)
                var titleField = child.Fields["Title"].Value;

                if (string.IsNullOrEmpty(titleField))
                    var nodeName = child.Name;
                    if (nodeName.IndexOf(" ") == -1)
                        //split string into words if CamelCase (or lowerCamelCase) is used
                        var nodeTitle = Regex.Replace(nodeName, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ");
                        child["Title"] = nodeTitle;
                        child.Appearance.DisplayName = nodeTitle;

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <form id="form1" runat="server">
        Root ID: <asp:TextBox Width="400px" ID="RootItemId" Text="" runat="server"></asp:TextBox>
        <asp:Button ID="Update" OnClick="UpdateFriendlyTitles_Click" Text="Update Friendly Field Titles" runat="server" />

Similar Posts