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>
Solved! Go to Solution.
Views
Replies
Total Likes
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
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
Thanks so much.
Views
Likes
Replies