This is the third post in the ‘Creating Your First Sitecore Page’ series. In the last article, How To Create A Master Data Template In Sitecore, we created a master template. The purpose of the master template is to define a schema for all the common properties that exists on all of our web pages. The page title is one such example. With our ‘master’ template created, we will now create a template for a standard content page.
Creating Your First Sitecore Page Template
To create our content page, we need to create a new data template. Content page templates are pretty basic, a usual content page obviously needs all the standard page template settings, so it will need to inherit from the master template. It will also need a way for content editors to add rich-text onto a page.
In the ‘templates‘ area within the Sitecore content tree, create a new template within a folder (I recommend creating a folder under templates, called your host). When you create the new template, you will obvious need to give it a name. You will also need to set the ‘base’ template to the master template we created in the last article.
The only real thing you’ll need in your content page template is a ‘Content’ section and a ‘page content’ property that allows ‘rich-text’ to be entered. Now we have a very basic master and page template set-up, we can create a content page.
How To Create A Page With A Data Template
To finish off this article, I’ll quickly run through how to create a page using our data template. In the Sitecore content tree, you should see a ‘Content’ item. This is the area where all your websites web pages will live.
If you right click on the ‘home’ item and select ‘Insert’ -> ‘Insert from template’. You’ll be presented with the template picker:
Select the ‘content page’ template, from within the templates section.
Now you can create your content page. As you can see above, the page content property loads the rich-text editor. In here, content editors can add and format text that we can later render out in a layout.
In the content page, we also have our common global properties that are inherited from the master template. As I’m hoping you can see, this template inheritance is pretty simple to implement but gives you a lot of power. You might not split your templates up as efficiently as possible on your first project, but, after a few sites, you’ll be a pro.
We still have quite a lot to do before we can display our page on our website. In the next lesson, I’ll cover layouts. The layout file is where we talk about HTML. The layout file is where we define how our site looks and what data should be displayed to the end user.