Page tree
Skip to end of metadata
Go to start of metadata

This page is about using YAML in Magnolia. YAML is a data serialization format designed for human readability and interaction with scripting languages. Use YAML to configure and define apps, dialogs, field types, message views and templates, media editor and renderers. You can define these same items using JCR nodes via Configuration app; YAML is just an additional possibility.


  • Whitespace indentation is used to denote structure; however tab characters are never allowed as indentation.
  • Comments begin with the number sign (#), can start anywhere on a line and continue until the end of the line. Comments must be separated from other tokens by white space characters. 
  • Strings (scalars) are ordinarily unquoted, but may be enclosed in double-quotes ("), or single-quotes (').

For a complete reference of the YAML syntax please check up or

Lists and Maps

Magnolia YAML files are always combinations of YAML maps and lists. (This said, make sure you understand the concept of these two structures.)


Members of a list are lines beginning at the same indentation level starting with leading hyphen (dash) and at least one space ( ). The number of spaces after the leading hyphen must be the same for all list members.

# A list of food
- Sandwich
- Pizza
- Burrito
- Chocolate cake


Maps (also known as dictionaries in YAML) are represented in a simple key: value  form (the colon must be followed by a space):

# An employee record
name: John Doe
job: Developer
skill: Beginner 

Combination of Map and List

Let's combine maps and a lists. (It is a common use case in Magnolia YAML files.)

# An employee record
name: John Doe
job: Developer
skill: Beginner
employed: True
    - Sandwich
    - Pizza
    - Burrito
    - Chocolate cake
drinks: [coke, beer, water, milk] # drinks is another example of another notation of a list
    groovy: Beginner
    java: Beginner
    freeMarker: Expert


  • The "root" structure of this file is a map.
  • The value of the map entries with the keys food and drinks are lists
  • The value of the map entry with the key languages again is a map

YAML in the context of Magnolia

YAML data is transformed to definition classes

YAML files are meant to configure or define "items" like apps, templates and dialogs. In a running system the data written in YAML is represented by a Java Bean. Below you find a table of Magnolia YAML files and their corresponding Magnolia classes (usually called definition or description class). 

ItemYAML fileCorresponding definition class*

* You also can use custom definition classes (which usually extend the classes mentioned above). In that case you must provide the class as an attribute in the YAML file.

Example: Using custom definition classes

Imagine you have your own template definition class com.example.magnolia.templates.CustomTemplateDefinition

package com.example.magnolia.templates;
public interface CustomTemplateDefinition extends TemplateDefinition{
	String getBodyClass;

The corresponding YAML file for this template definition would look like this:

class: com.example.magnolia.templates.CustomTemplateDefinition
renderType: freemarker
templateScript: /example-project/templates/pages/defaultTemplate.ftl
title: Default template
visible: true     
bodyClass: default-layout       

YAML data is transformed by Map2BeanTransformer. Magnolia uses snakeyaml to parse data.

The name property

A definition class often has a property name.

public class FooBarDefinition {
    private String name;
    private boolean abc;
    private boolean xyz;

    public String getName() { return name; }
    public void setName(String name) { = name; }
    public boolean getAbc() { return abc; }
    public void setAbc(boolean abc) { = abc; }
    public boolean getXyz() { return xyz; }
    public void setXyz(boolean xyz) { = xyz; }

Imagine fooBar is an item within a YAML configuration file.

If fooBar is an entry within a map, the key can be used as the value for the property name. (However it can be overridden.)

      java: good
      ftl: excellent
    miscellaneous: # here the item miscellaneous is a map
      musical: False
        # name: offBar (the property 'name' can be set. If not, the key is used!)
        abc: True
        xyz: False

If fooBar is an item within a list, the name property must be set explicitly.

      java: good
      ftl: excellent
    miscellaneous: # here the item miscellaneous is a list
      - musical: False
      - fooBar
          name: fooBar
          abc: True
          xyz: True

Differences between YAML file and JCR node based configuration data

YAML configuration has some benefits and disadvantages over JCR node based configuration. See Configuring in JCR vs YAML.

Include mechanism 

Instead of adding a list item or a value of a map entry you can include a file.

  label: Example page properties
    - name: tabText
      label: Texts and categories
        - name: title
          class: info.magnolia.ui.form.field.definition.TextFieldDefinition
          label: Title and categories
          i18n: true
        # an include within a list, here adding a field
        - !include /documentation-examples-templates/dialogs/common/categorization-field.yaml
# an include within a map, here adding a tab
actions: !include /documentation-examples-templates/dialogs/common/actions-block.yaml

The !include directive is Magnolia specific. The ! is a special character in YAML for a non-specific tag, see

Path conventions:

  • Absolute path starting with /<module-name>. (This directory within a Maven-based module would be src/main/resources/<module-name>. See Module structure).
  • Same kind of definitions only. The file which includes and the file to be included must be of the same type.
    • (tick) file /my-module/dialogs/mydialog.yaml can include /my-module/dialogs/common-actions.yaml 
    • (tick) file /my-module/dialogs/mydialog.yaml can include /mte/dialogs/default-actions.yaml 
    • (error) file /my-module/dialogs/mydialog.yaml cannot include /my-module/apps/actions.yaml 

Exporting JCR configuration to YAML

You can export JCR data from the config workspace to YAML. This is useful for moving from repository-based configuration to file-based configuration.

YAML export is available for all definition items that can be configured in YAML:

The Export to YAML action is disabled for other items.

When using YAML files originating from export, you might have to change the file name if you want to use it within a module; for instance the name of the YAML file defining an app must reflect the app name with the pattern <app-name>.yaml.


Editors supporting YAML syntax

Online YAML parser