Structure

Last updated on 30th September, 2017 by George Taylor

Content in AEM is always below the /content node, usually it would be /content/<site>/<locale>, while this is a basic standard, there is no fixed requirements on structure and you tend to use sling mappings to map a real website url to where your content actually exists.

when you deploy content in AEM you use a .content.xml file for the physical content, and can either have it's sub nodes as items in the xml, or as new folders with their own .content.xml. The standard is to have all content in the jcr:content node within the page's .content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:designPath="/etc/designs/sample"
cq:cugEnabled="false"
cq:lastModified="{Date}2016-07-19T16:12:31.788+03:00"
cq:lastModifiedBy="admin"
cq:template="/apps/sample/templates/application-page"
jcr:primaryType="cq:PageContent"
jcr:title="Login"
sling:resourceType="sample/components/structure/application-page">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/parsys">
<login
jcr:primaryType="nt:unstructured"
sling:resourceType="sample/components/content/login"/>
</par>
</jcr:content>
</jcr:root>

In this example we have a basic page of type application-page that has a parsys and inside the parsys is a single component called login

Each page in AEM has to have a jcr:content node with the details of the page itself.

We would also then deploy a _rep_policy.xml file with it if it needs to modify any ACL's for itself and it's child nodes.

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
jcr:primaryType="rep:ACL">
<allow
jcr:primaryType="rep:GrantACE"
rep:principalName="everyone"
rep:privileges="{Name}[jcr:read]"/>
</jcr:root>

The default structure is to add each page required, and sub pages below the parent i.e.

  • content
    • site (sample)
      • locale (en_GB)
        • index
          • page1
            • page1 child
          • page2

It is possible to add pages that have no content and wouldn't actually be seen by the users. For these i recommend you put in a redirect page to a known proper location

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:designPath="/etc/designs/sample"
jcr:primaryType="nt:unstructured"
jcr:title="Sample Folder Page"
sling:redirect="{Boolean}true"
sling:redirectStatus="{Long}302"
sling:resourceType="foundation/components/redirect"
redirectTarget="/index/page1">
</jcr:content>
</jcr:root>

One thing that you will notice in both of the pages that i specified, they both have an attribute cq:designPath, this is what tells AEM where to look for the design for this particular tree of pages.

The design is not mandatory, and can be chosen by the author at a later point of time, but i recommend setting it as part of the content deployment so you know what the pages will look like. The design is inherited by all pages below it unless they specify a specific design of their own.