Setting up Enonic


In this chapter, we will build a custom app based on the HMDB project, and play around with the Headless API

For an in-depth introduction to Enonic, visit the official Enonic Developer 101 guide.

Enonic at a glance

Our platform is actually called Enonic XP (XP, or Enonic for short).

Enonic apps

Enonic XP allows you to install and run one or more applications in a single instance.

You can discover ready to run applications on Enonic Market, or you may build your own, like we will be doing in this tutorial. Each app may provide specific functionality. It may for instance be everything you need for a large website, or provide only specific services, such as an API. An app is given an app name when it’s built.

Apps may provide a range of different functionality. For this tutorial we will focus on headless CMS capabilities.

Useful terminology: A sandbox is a local Enonic server running on your laptop. Apps are built from projects which are basically a folder that contains the app’s source code. Once it is built, it can be deployed to the sandbox - where it will be started and made available.

For production use and CI/CD, Enonic apps may be installed in many different ways, typically using enonic CLI. In some cases, apps may even be installed directly via the Enonic Admin console.


Apps typically ship with one or more content types. Content types typically define data structures (similar to fields in classes in object-oriented languages). Each content type gets a unique name which is automatically pre-fixed with the app-name. e.g. <appName>:<contentTypeName>.

Content types are used to create content items. Content is commonly created and handled via Enonic’s Content Studio. Content may be organised in tree structures, which can be useful both for internal purposes, but also externally - as we will see in this tutorial.

All content items get a unique path name when creating it - this is similar to a filename - and a human-friendly displayName.

Content can exist on two different branches: When creating or editing in Content Studio, you’re always working on the draft branch. When publishing, new items and changes are copied to the master branch - which is often publicly accessible.

The Headless Movie Database

With Enonic, you may obviously create your own content model, but to save time, we’ll be using a demo-app known as the Headless Movie Database (HMDB) as our starting point.

HMDB ships with a pre-defined content-model and some useful sample content. It also exposes the content through a graphQL API. This API gives us access to the content.

Let’s get going!

Task: Create application from template

  1. Install the Enonic CLI (follow link for instructions).

  2. Create a new project using the "Headless movie database" as your template:

    Run the following command from your terminal

    enonic project create -r app-hmdb
    Stick with the standard values and keep the suggested project name com.example.myproject for the examples in the tutorial to work properly. This will be referred to as app name later in this tutorial.
  3. Deploy the application by running this command from your freshly created project folder.

    enonic project deploy

    The application will now be built. When asked to start a sandbox (a local instance of XP running its own content storage area), hit Yes. Enonic starts, outputs some server logs, and the sample content is imported.

  4. Install and test Content Studio.

    Navigate to http://localhost:8080 and log in to the admin console (you don’t have to create a user for this tutorial).

    Install Content Studio (it’s an XP app of its own) by completing the XP Tour , or via the Applications admin app.

    From the XP menu, open Content Studio, and choose the Headless demo project if needed. You should see something like this:

    hmdb content

    Some items have a default preview. That’s okay for now - as we will customize this preview later.

Congrats on setting up the Enonic development environment

With the SDK running, lets have a look at the headless API.