Expand my Community achievements bar.

Get ready! An upgraded Experience League Community experience is coming in January.

Best way to delete content fragment at language master level and in all live copies

Avatar

Level 2

Hi,

We are using AEM cloud and got a request to delete a content fragment from language master as well as all the live copies (around 150).  Could anyone suggest a best and clean approach as we don't want to have unforeseen issues later. 

 

For now, I am contemplating the below. 

 

unpublishing all live copies -> delete content fragment at language master  -> delete all live copies

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

3 Replies

Avatar

Level 10

hi @LK-CMS,

you should treat it as an asset cleanup exercise plus an MSM cleanup exercise and do it in a controlled way.

1. Inventory all usages first

  • Use the References panel (from the fragment in Assets/Content Fragments console) to list all pages and fragments that reference this fragment across all language copies.

  • Optionally run or build a small report to export all usages (example here)

2. Decide what should happen in live copies. Typical options:

  • Remove the CF component from the pages in live copies.

  • Replace the CF reference with another fragment.

3. Clean up references in language master and live copies

  • For each referenced page, remove or replace the CF component, starting with the language master and then syncing changes out with MSM where inheritance is still active.

  • Where authors have already cancelled inheritance on the CF component in specific locales, adjust those pages manually or via a scripted update (Groovy/HTTP API) so that no pages still reference the fragment.

4. Unpublish the fragments, master and live copies

5. Delete the fragments in DAM

 

For automation, you could also consider a Groovy console/script in a non‑prod environment to:

  • Enumerate all CF live copies under your DAM folder.

  • Check for page usages.

  • Remove or replace references and then delete the CFs.

Avatar

Community Advisor

Hi @LK-CMS ,

Your approach is on the right track, but here's the cleanest sequence:

Unpublish from language master - This should cascade to all live copies automatically

Delete from language master - This will break the inheritance relationship

Delete live copies - Now safe to remove individually

 

Better alternative if you have many live copies:

Use Groovy Console or AEM Package Manager with a script to:

Unpublish all instances in one go

Delete language master

Batch delete all live copies by path pattern

 

Unpublishing first prevents orphaned published content. Deleting the master first breaks inheritance cleanly, preventing sync issues.

Caution: If live copies have local modifications you want to preserve elsewhere, document those first before deletion.

 

Hrishikesh Kagane

Avatar

Employee

Hello @LK-CMS 

Other than deleting 150+ Content Fragment live copies manually in the UI, you can also use the newer Content Fragments and Model Management OpenAPI (AEM Sites CF Management API) as a safer, automated alternative: by scripting against endpoints like

DELETE /adobe/sites/cf/fragments/{fragmentId}/deleteAndUnpublish

you can bulk delete and unpublish fragments in a single call, while the API enforces reference‑safety (returns 409 when a fragment is still referenced), uses ETags for concurrency control, and provides clear HTTP statuses and request IDs for audit and rollback.

This approach lets you :
(1) reliably apply the recommended order (delete child/live‑copy fragments before the language‑master),
(2) avoid "orphan on publish" situations because unpublish is handled together with delete,
(3) encode your governance rules once (e.g., "never delete if referenced by other CFs") instead of relying on individual authors, and
(4) reuse the same script for future clean‑ups or migrations, turning what would be a fragile, one‑off UI operation into a repeatable, testable process.

Reference :
https://developer.adobe.com/experience-cloud/experience-manager-apis/api/stable/sites/#operation/fra...