Learn about Creating Content Fragment Models in AEM architect-headless-content-fragment-models

The Story so Far story-so-far

At the beginning of the AEM Headless Content Author Journey the Content Modeling Basics for Headless with AEM covered the basic concepts and terminology relevant to authoring for headless.

This article builds on these so you understand how to create your own Content Fragment Models for your AEM headless project.

Objective objective

  • Audience: Beginner
  • Objective: the concepts and mechanics of modeling content for your Headless CMS using Content Fragments Models.

Creating Content Fragment Models creating-content-fragment-models

Then the Content Fragments Models can be created and the structure defined. This can be done under Tools > General > Content Fragment Models.

Content Fragment Models in Tools

After selecting this you navigate to the location for your model and select Create. Here you can enter various key details.

The option Enable model is activated by default. This means that your model is available for use (in creating Content Fragments) as soon as you have saved it. You can deactivate this if you want - there are opportunities later to enable (or disable) an existing model.

Create Content Fragment Model

Confirm with Create and you can then Open your model to start defining the structure.

Defining Content Fragment Models defining-content-fragment-models

When you first open a new model you see - a large blank space to the left, and a long list of Data Types at the right:

Empty Model

So - what’s to be done?

You can drag instances of the Data Types onto the left space - you are already defining your model!

Defining fields

After you add a data type you are required to define the Properties for that field. These depend on the type being used. For example:

Data Properties

You can add as many fields as you need. For example:

Content Fragment Model

Your Content Authors your-content-authors

Your content authors do not see the actual Data Types and Properties that you have used to create your models. This means that you might have to provide help and information on how they complete specific fields. For basic information you can use the Field Label and Default Value, but more complex cases project specific documentation might need to be considered.

NOTE
See Additional Resources - Content Fragment Models.

Managing Content Fragment Models managing-content-fragment-models

Managing your Content Fragment Models involves:

  • Enabling (or disabling) them - this makes them available for authors when creating Content Fragments.
  • Deleting - deletion is always needed, but you need to be aware of deleting a model that is already used for Content Fragments, in particular fragments that are already published.

Publishing publishing

Content fragment models need to be published when/before any dependent content fragments are published.

NOTE
If an author tries to publish a content fragment for which the model has not yet been published, a selection list indicates this and the model is published with the fragment.

As soon as a model is published it is locked into a READ-ONLY mode on author. This aims to prevent changes that would result in errors to existing GraphQL schemas and queries, especially on the publish environment. It is indicated in the console by Locked.

When the model is Locked (in READ-ONLY mode), you can see the contents and structure of models but you cannot edit them directly; though you can manage Locked models from either the console, or the model editor.

What’s Next whats-next

Now that you have learned the basics, the next step is to start creating your own Content Fragment Models.

Additional Resources additional-resources

recommendation-more-help
fbcff2a9-b6fe-4574-b04a-21e75df764ab