AEM Champion Office Hours: Content Fragments (August 2023)

RENY's Rami El Gamal and fellow AEM Champions answer Content Fragment questions: model design, GraphQL, preview, IDs, quizzes, JSON export and MSM.

This AEM Champion Office Hours session, recorded in August 2023 and hosted by Brett Birschbach, focused on Content Fragments. The panel of AEM Champions, including RENY director Rami El Gamal, Greg Dimeris, Martin Noble and Max Barrass, answered questions on modeling, delivery and governance of structured content in AEM.

What the session covers

  • Modeling: how to design Content Fragment models around use cases, and who should be involved.
  • Delivery: GraphQL queries, nested references and the ways to export fragments as JSON.
  • Authoring features: the Content Fragment preview button and persistent IDs.
  • Choosing the right tool: when to use Content Fragments, Experience Fragments or components, with examples such as footers and quizzes.
  • Limits: multi-site management (MSM) support, and writing data back into AEM.

Key takeaways

  • Model around use cases. Gather input from authors, developers, architects and whoever manages your content library before creating models. Breaking content into fields is a data-modeling skill, much like database schema design.
  • Let GraphQL shape the response. Ask only for the fields you need, include referenced content in the same query, and cache the results instead of parsing large JSON feeds in the front end.
  • Paths are not stable IDs. Fragment IDs change when content moves between environments, and authors can move or rename fragments. If you need a permanent identifier, add a field for it and restrict who can move content.
  • HTML belongs in Experience Fragments. Footer links and other page furniture that ends up as HTML gain nothing from Content Fragments.
  • Content-heavy, reusable items suit Content Fragments. A quiz is a good example: each question becomes a fragment with fields for answers, so questions can be reused across quizzes.
  • Content Fragments do not fully support MSM live copies, so plan multi-site reuse differently.
  • AEM delivers content; it is not a database. APIs can create and update fragments, but use them for specific cases such as bulk imports, not to collect user-generated data.

RENY's perspective

The Content Fragment preview button needs nothing from Adobe: it is driven by the SDK, so keep your SDK and environments current. We lean toward code-driven Content Fragment models, because turning the data into something useful on a page always needs some development, and we advise against creating Content Fragments only to query them with GraphQL and render them back in AEM pages. For content such as quizzes, make each question a fragment rather than building one huge component dialog. We see headless delivery and feeding other systems, such as an e-commerce site, as GraphQL's main use cases, and remember that reverse replication is gone in Cloud Service.

What's changed since 2023

  • A new Content Fragment editor and console are now the default in AEM as a Cloud Service, and the Universal Editor can edit Content Fragments in context.
  • OpenAPI-based APIs for Content Fragment delivery and management complement GraphQL for headless use cases and for creating or updating fragments programmatically.
  • Check Adobe's current documentation for multi-site options for Content Fragments, as this area continues to evolve.

How RENY helps

We design Content Fragment models, GraphQL and API delivery, and content governance for headless and hybrid AEM sites. Talk to an AEM architect.

Watch on YouTube: AEM Champion Office Hours: Content Fragments (August 2023)

Related service: AEM Sites & Edge Delivery Services