Best Practice: Working with Data Templates, Fields and items
While working on the Sitecore projects, I have found that many developers do not follow best practices while creating templates/fields/items which should cause issues later on. Once the project started with bad naming conversions, it is hard to change the name of templates/fields/items as well as the folder structure.
Here in the article, I’m providing some best practices which I’ve found so useful during my work. Some of the best practices are recommended by Sitecore as well which we learn while preparing for the Sitecore certification.
- Make sure you provide easy-to-understand, simple and most importantly relevant names for templates, sections and field. Avoid any ambiguious or confusing names to make your and other Sitecore developers’ life easy
- By default Sitecore displays the names of the item you provide to both technical and non-technical users.
- Provide names such that business users, like Content Authors can easily identify and understand.
- As a very good best practice, while creating an item/template input the name without space or use hypen (-) to separate words. After creating the item with desirend name, set the Display name for that item to make sure non-techical users like Content Authors can easily recognize the items/fields.
- While you create a new page item, which should be accessed through URL, then make sure you must avoid space in the name of the item, and use hypen (-) to separate workds if the item name consists of more that one word. By following this practice, you make the page items SEO friendly automatically and you will never see %20 in the URL.
- Provide a clear folder structure that classifies by feature/project/site section/section content or function etc.
- Having proper folder structure while creating templates makes it easier to find and navigate to a particular template item.
- Having proper folder structure while creating actual data items also helps to organize the items by their type/function.
- Field names are most important and they must be unique. You should be careful while creating fields and make sure no two fields have the same name in the inheritance chain of templates.
- Use the same best practice of provide name without space or use hypen(-) to separate words and use the display name for better meaningful name
I hope this short but useful information will help you in your projects!!!