Aem Content fragments | Community
Skip to main content
Level 1
June 15, 2026
Question

Aem Content fragments

  • June 15, 2026
  • 2 replies
  • 72 views

I have a requirement on  designing Aem content fragment models & graphql endpoint for a mega menu. Where the menu items stored in content fragments currently. I am facing challenge with deeply nested fragment structure( Around 4-5 levels). I want to avoid this nested structure and the requirement is to use the content fragments.  Using json objects is also not suggestable because of business authoring.

Suggest the best way to solve this any new way of using CF.

2 replies

v-lazar
Level 2
June 15, 2026

@Sudeep, deep nesting in Content Fragments is a known anti-pattern in AEM Headless. Past two or three levels you hit GraphQL resolver fan-out, persisted query bloat, and fragmented caching that makes the structure expensive to deliver and harder to author. There are many patterns how you can do it, but here is how I would do it with limited knowledge about your setup.

 

Implement it via page tree plus shallow CFs. Use the AEM page tree as the source of truth for the menu hierarchy, the way AEM Sites traditionally handles navigation.

CFs hold only the content payload (label, link, image, description) for each node. Hierarchy is implicit in the page path. It aligns with how authors already think about site structure, and the page tree UI is far better than nested CF editing.

https://www.linkedin.com/in/viktor-lazar/ | https://cyber64.com/insights
SudeepAuthor
Level 1
June 16, 2026

Hi ​@v-lazar , Thanks for the suggestion but the header content is not from AEM sites it consists multiple other site references which is not part of AEM. So, we have to author all the links in CF. we can assume like the header has mainly 4 dropdowns. Under each dropdown it will have multiple columns of links which may vary. This makes the me to have multiple fragment references as each link requires id, label, href… By this way authoring is becoming complex. 

HrishikeshKagne
Community Advisor
Community Advisor
June 15, 2026

Hi ​@Sudeep ,

I would avoid creating a Content Fragment structure with 3-4 levels of nested Fragment References. While it may look like the natural way to represent a menu hierarchy, it makes GraphQL queries complex, impacts performance, and becomes difficult for authors to maintain. A better approach is to keep the Content Fragment model relatively flat. Store each menu item as an individual Content Fragment and use fields such as ID, Parent ID, Title, and Link to define the hierarchy. The GraphQL query can then fetch all menu items in a single request, and the application can build the menu tree using the Parent ID relationship. This approach keeps authoring simple, improves GraphQL performance, reduces dependency on deeply nested references, and allows the menu structure to grow without requiring changes to the Content Fragment model. In general, limiting Fragment References to one or two levels is a good practice for scalable and maintainable AEM implementations.

Hrishikesh Kagane