Exclude Experience Fragments from page publication in custom AEM workflows
This article explains how to update a custom Adobe Experience Manager (AEM) workflow so that Experience Fragments are not published alongside pages, allowing Experience Fragments to be managed and published on a separate schedule.
Description description
Environment
- AEM Sites instance with a custom page-publication workflow
- Custom workflow collects references and submits page and reference paths for replication
Issue/Symptoms
- The custom workflow uses
ReferenceProvider.findReferences()to collect all referenced content and then publish both the page and its references usingReplicator.replicate(). - Referenced Experience Fragments are published with the page, even when authors manage and publish those fragments on a separate schedule.
- The standard Manage Publication flow lets authors deselect references. The custom workflow doesn’t provide that option unless the workflow implements it.
- The custom workflow needs a deterministic rule to exclude Experience Fragment references before it submits paths for replication.
Cause
The custom workflow includes Experience Fragment paths in the list it submits for replication. Because the workflow doesn’t filter those paths, the referenced Experience Fragments are published with the page. The standard Manage Publication flow has a reference-selection control, but a custom workflow must implement its own filtering or selection logic.
Resolution resolution
Follow the steps below to resolve the issue.
-
Update your custom
WorkflowProcessimplementation to exclude Experience Fragment references before invokingReplicator.replicate(). -
After retrieving references through
ReferenceProvider.findReferences(), identify any references that point to Experience Fragments. Experience Fragments are typically stored under the/content/experience-fragmentspath. -
Filter out Experience Fragment paths before replicating the collected references. The following example shows one approach:
code language-none // Collect references List<Reference> references = referenceProvider.findReferences(resourceResolver, pagePath, ...); // Filter out Experience Fragments List<String> pathsToReplicate = references.stream() .map(Reference::getTargetPath) .filter(path -> !path.startsWith("/content/experience-fragments")) .collect(Collectors.toList()); // Add the page path itself pathsToReplicate.add(pagePath); // Replicate only the filtered paths for (String path : pathsToReplicate) { replicator.replicate( session, ReplicationActionType.ACTIVATE, path ); } -
If additional validation is required, resolve each reference target and verify that it is an Experience Fragment by checking its resource type or by using the Experience Fragment API available in your AEM version.
-
Deploy the updated workflow and publish a test page.
-
Verify that the page is published successfully and that referenced Experience Fragments are not replicated unless they are published separately.