Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

How to set default policy for XF template in AEM

Avatar

Level 5

How do I set 2 default policies for an Experience Fragments in AEM? Currently when I have to create a new XF, I need to navigate to General --> Templates every time and define the page policy with the correct policy for the client libs.

    <jcr:content
        cq:lastModified="{Date}2025-07-16T11:13:40.354-04:00"
        cq:lastModifiedBy="admin"
        cq:policy="wcm/foundation/components/page/policy"
        jcr:primaryType="nt:unstructured"
        sling:resourceType="wcm/core/components/policies/mappings">
        <root
            cq:policy="jhi-experience-fragments/foundation/components/responsivegrid/policy_84186787001333"
            jcr:primaryType="nt:unstructured"
            sling:resourceType="wcm/core/components/policies/mapping"/>
        <anotherRoot
            cq:policy="jhi-experience-fragments/foundation/components/xfpage/policy_1752691690759"
            jcr:primaryType="nt:unstructured"
            sling:resourceType="wcm/core/components/policies/mapping"/>
    </jcr:content>

stiegjo22_0-1752787035714.png

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @stiegjo22,

Setting default policies for Experience Fragments (XF) is usually done via a template-level configuration, not directly in the XF itself. You're on the right track by looking into the wcm/core/components/policies/mappings, but to avoid manually assigning policies every time you create a new XF, follow the method below.

Automate default policy assignment for new Experience Fragments, configure the template structure (/conf/your-site/settings/wcm/template-types/xf-page/structure) to include the policies.

1. Locate your XF Template Type

Path:

/conf/your-site/settings/wcm/template-types/xf-page

Inside this template type, go to:

/conf/your-site/settings/wcm/template-types/xf-page/structure/jcr:content

2. Set the cq:policy on the correct nodes

Example structure with two nodes:

/conf/your-site/settings/wcm/template-types/xf-page/structure
└── jcr:content
    ├── root (sling:resourceType: wcm/foundation/components/responsivegrid)
    │   └── cq:policy = jhi-experience-fragments/foundation/components/responsivegrid/policy_84186787001333
    └── cq:policy = jhi-experience-fragments/foundation/components/xfpage/policy_1752691690759
  • jcr:content/@cq:policy: sets the policy for the xfpage root

  • jcr:content/root/@cq:policy: sets the policy for the responsivegrid


Santosh Sai

AEM BlogsLinkedIn


View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi @stiegjo22,

Setting default policies for Experience Fragments (XF) is usually done via a template-level configuration, not directly in the XF itself. You're on the right track by looking into the wcm/core/components/policies/mappings, but to avoid manually assigning policies every time you create a new XF, follow the method below.

Automate default policy assignment for new Experience Fragments, configure the template structure (/conf/your-site/settings/wcm/template-types/xf-page/structure) to include the policies.

1. Locate your XF Template Type

Path:

/conf/your-site/settings/wcm/template-types/xf-page

Inside this template type, go to:

/conf/your-site/settings/wcm/template-types/xf-page/structure/jcr:content

2. Set the cq:policy on the correct nodes

Example structure with two nodes:

/conf/your-site/settings/wcm/template-types/xf-page/structure
└── jcr:content
    ├── root (sling:resourceType: wcm/foundation/components/responsivegrid)
    │   └── cq:policy = jhi-experience-fragments/foundation/components/responsivegrid/policy_84186787001333
    └── cq:policy = jhi-experience-fragments/foundation/components/xfpage/policy_1752691690759
  • jcr:content/@cq:policy: sets the policy for the xfpage root

  • jcr:content/root/@cq:policy: sets the policy for the responsivegrid


Santosh Sai

AEM BlogsLinkedIn


Avatar

Level 5

Thanks so much.