Create the first AEM template

In the last session, we have explored templates using CRXDE Lite. If you have not yet gone through the last session, go through it.  In this session, we will create a sample template using CRXDE Lite. Let us first get into the shoes of authors to see where exactly authors use a template in their content creation workflow.

  1. Open SiteAdmin. http://localhost:4502/siteadmin
  2. Log in with admin/admin credentials.
  3. In the left pane, go to Geometrixx Demo Site > English.
  4. From the right pane, select New > New Page.
    You see the Title and Name text boxes. (Title appears in the web page and Name becomes the URL.

What you see underneath, namely Geometrixx Content Page, Geometrixx Home Page, Geometrixx Form, are templates. They define the layout of your page.
In that sense, choosing the right template is a fundamental part of content creation.

  1. Now log into CRXDE Lite.
  2. Go to the Apps folder. We have seen earlier that apps is the folder where we create templates and components.
  3. Inside apps, create a new folder.
  4. Right-click apps and select Create Folder.
  5. Type aem-company. (This is our sample company.)
  6. After creating the company, click Save All to save the company. (Whenever you create a node, folder, or property, you need to save explicitly in CRXDE Lite.)
  7. In the similar way, inside aem-company, create two more folders: components and templates.

Now log into CRXDE Lite and create the first template.

  1. Now, right-click templates and select Create Template.
  2. Enter the following details:
  • Label: homepage
  • Title: AEM Company Home Page
  • Description: AEM Company’s Home Page Template
  • Recourse Type: aem-company/components/homepage
    This is the sling:resourseType property. We have seen that, it points to the rendering script. Right now, we have pointed it to a component that doesn’t exit. We will create that script shortly.
  • Ranking: You could leave it for the time being. It represents the order in which templates should appear.
  1. Click Next and enter Allowed Paths as /content(/.*)?. Means the template will apear in the content folder where all pages exist.
  2. Click Next till you see the Finish button.
    (We will learn about these properties at a later stage.)

Now, let us create the rendering script. We create the rendering script as a part of the component. We have already seen that, a component displays a specific information in a specific format. In this case, the component that we are going create, provides the layout of the page. It’s not a component that you can drag and drop to a page. We will name the component as homepage, so that we can identify it as a page component – or a component provides the layout of a page.

  1. Right-click the components folder and select Create > Create Component.
  2. Enter the following details.
  • Label: homepage
  •  Title: AEM Company Home Page Component
  • Description: AEM Company’s Home Page Component
  • ResourceSuperType: wcm/foundation/components/pageThis property decides the component from where you want to inherit properties that decide your page’s behavior.
    You have seen that the pages authors create have a sidekick, assets tab, and so on. We have pointed this to a page component that exists.
    Group: AEM Company

Note that, homepage component is created. It also adds a default rendering script: homepage.jsp. I have mentioned earlier that we used to create components using JSPs before. That’s the reason for the JSP extension. In this session, we will create the template using Sightly, because it’s HTML and easy to use.

Just rename the homepage.jsp to body.html. This is a very important step. The SuperType property points to wcm/foundation/components/page. Though we have not explicitly mentioned, this component exists in the libs folder. Let us locate it. Navigate to libs > wcm > foundation > components > page.

By providing this as the SuperType, we are inheriting the scripts the component has. Go to the page.html which is the rendering script. This script includes two pages: head.html and body.html. By renaming the homepage component’s rendering script’s name to body.html, we are overwriting the body.html. At the same time, we will inherit head.html. (I have explained in the simplest possible way. Let us have a detailed discussion about it later.)

Open the aem-company’s body.html and add some text. Now, go to siteadmin, create a new page. You will see the template you created. Create a page – AEM Company. Open the page and you will see the text you entered. We will modify the template further in the coming sessions.

Comments are closed.