Tailwind Logo

Creating Root Items

Next.js

Published: 2022-04-21

Up until now, items created as Next.js-based samples have been created based on the root item created when importing JSS samples. This time, we will introduce the procedure for creating the equivalent of a root item.

Create a base template

We will be creating a new template so that we can better handle the content structure to be managed on the site in the future. First, we will create a base template. The templates will be created in the following folders

  • /sitecore/templates/Project/sitecoredemo-jp

First, create a template folder. Click on the "Template Folder" button to make it the Common folder.

route01.png

With the created folder in place, click the New Template button. In this case, we will name the template Page. The base template can proceed as the standard template.

route02.png

As the field item in the Page template, the field section is Content, the pageTitle is Singleline Text, and the pageContent is the RichText field.

route03.png

Then select the Builder option from the Content Editor menu to specify the base template.

route04.png

The base template should be Route under Template - Foundation - JavaScript Services.

route05.png

Save the template once, this time clicking on Standard Values in the Builder Options menu. Complete the Standard Value setup by specifying $name in the Title field.

route06.png

Next, create a template for metadata. The template name is _Metadata.

route07.png

As for fields, create a Metadata field section and a field called pageDescription.

route08.png

Create a template

Now that we have created two base templates, we will go on to create the home template. This time, instead of a folder called Common, we will create a folder called Pages.

route09.png

Next, we will create the Home template, but we will create it as a standard template.

route10.png

Specify the above two templates, Page and _Metadata, as the base template.

route11.png

The home item icon designates an item in the network as shown below.

route12.png

The root item is now complete.

Create an item

Let's create an item based on the template we have just created. First, right-click /sitecore/content/sitecoredemo-jp in the content tree and select Insert - Insert from Template.

route13.png

When selecting Insert from Template, specify the Home template you just created. In this case, the item name is Home Test.

route14.png

You can see that the item has been created and the title contains the item name with $name enabled.

route15.png

Summary

You can now create a new template to create an item. In this case, we have created a template called `Home`. In the next article, we will proceed to set up and configure the layout to display this template.

Tags