Blogs > Content Fragments in AEM
AEM Sites
Content Fragments in AEM
| October 10, 2024Hi, welcome to another blog.
Content fragments in AEM
today we will be focusing upon what is a content fragment, why is it used and how exactly can we create one.
Introduction
In Adobe Experience Manager (AEM), Content Fragments are pieces of content that are created in a structured way and can be reused across different pages, apps, and channels. Think of them as building blocks for content that can be shared and used consistently, whether you’re working on a website, a mobile app, or even an email campaign.
A Content Fragment Model is essentially a template that defines what kind of content you can have in a fragment — like text, numbers, dates, and so on. It helps organize and structure content so it can be reused easily across your platforms.
Aids Content Fragments Provide
Content fragments actually make work alot easy by providing
-
Structured Content : Instead of just throwing in random text, content fragments are organized by fields like titles, body text, dates, and more. This structure makes it easy to manage and reuse.
-
Reusability : Content fragments aren’t limited to one page or project. Once you create one, you can use it anywhere—on a website, in an app, or in emails. This saves you from copying and pasting the same content over and over.
-
API Access : Need to pull content from AEM into another system? No problem. Content fragments can be accessed through AEM's GraphQL API or REST APIs to serve content everywhere.
Hence, they help in dynamic content injection, maintain consistency and multichanel delivery.
Creation of Content Fragments
Now having an idea of this powerful feature of aem, lets try and create one. We will be creating a for the purpose of storing data of varios stars.
-
First we need to create a Content Fragment Model. Navigate to content fragment model from tools.
-
In this model, we need to add the fields of the content fragments. We can specify the field labels, their data types, property types and various other properties.
-
Here we have a text field, a multifield, a boolean field, a date field and a numfield.
-
After creating a model we are ready to create various content fragments using this model. In order to do so, navigate to Assets and create a folder stars.
-
Now we need to add cloud configurations to this folder so that it allows the creation of content fragments. To do so go to its properties, navigate to cloud configurations tab and then add the path of the folder in which we have our content fragment model.
-
Having added the cloud configurations, simply create the content fragment using the model and add the respective data.
Conclusion
This is how we create content fragments whose data can be exported by graphql or as a REST API.
I hope you ejoyed this learning.