The 5.7 branch of Magnolia reached End-of-Life on December 31, 2023, as specified in our End-of-life policy. This means the 5.7 branch is no longer maintained or supported. Please upgrade to the latest Magnolia release. By upgrading, you will get the latest release of Magnolia featuring significant improvements to the author and developer experience. For a successful upgrade, please consult our Magnolia 6.2 documentation. If you need help, please contact info@magnolia-cms.com.

This page explains how to create and use a light module. The light module will host the files for the templates and other things.

Create a module folder

Create the following folder structure on your computer:

$myDir/
└── my-first-website-tutorial
    └── one-pager-module
        ├── dialogs
        │   ├── components
        │   └── pages
        ├── includes
        ├── templates
        │   ├── components
        │   └── pages
        └── webresources

 $myDir can be anywhere but it must be a real directory such as:

  • Mac OS X /Users/johndoe/magnolia
  • Windows C:\Users\johndoe\magnolia

We recommend that you create the files and folders by hand. You can download the one-pager-module and its complete contents for reference. But be aware you get the final state of the files, like at end of the tutorial. 

When creating a name for a module, do not use spaces, accented characters such as é, à, ç, ä, öü or special characters such as slashes /\ and so on. The name must match the regular expression [a-zA-Z0-9-_].

Create a light module with the Magnolia CLI

Using the Magnolia CLI you can create the folder structure for a light module with the command create-light-module. Open a shell, cd to your light modules directory, and execute the following command:

mgnl create-light-module one-pager-module
When creating a name for a module, do not use spaces, accented characters such as é, à, ç, ä, öü or special characters (e.g. slashes /\ and so on). The name must match the regular expression [a-zA-Z0-9-_] .

Note that this only works if you have installed Magnolia CLI, see Magnolia CLI Installation.

Set magnolia.resources.dir property 

magnolia.resources.dir is a property defining the directory from which resources are loaded in a Magnolia instance. This directory is used for file-based resources such as light modules and for overriding classpath resources. The property is configured in WEB-INF/config/default/magnolia.properties and has the default value $magnolia.home/modules. To see the current value of the property, go to the Config Info tab in the About Magnolia app.
(info) You can use symbolic links (a.k.a symlinks or soft links) in the resources directory to include light modules located elsewhere on your system.

If you installed Magnolia using Magnolia CLI, the default for the magnolia.resources.dir is the light-modules directory created where you executed the jumpstart command. This assumes you did not use the -p option to specify another location for the light-modules folder.

To change the directory from which resources are loaded:

  1. Stop Magnolia. Go to the magnolia-x.y/apache-tomcat-x.y/bin directory and type:

    Mac OS X, Linux, Solaris
    ./magnolia_control.sh stop
    Windows
    ./magnolia_control.bat stop
  2. Edit the magnolia-x.y/apache-tomcat-x.y/webapps/magnoliaAuthor/WEB-INF/config/default/magnolia.properties file and set the magnolia.resources.dir property. Replace <$myDir> with the actual path to your module folder.

    magnolia.properties
    magnolia.resources.dir=<$myDir>/my-first-website-tutorial/light-modules

    Example on Windows. (warning) Note forward slashes!

    magnolia.properties
    magnolia.resources.dir=C:/Users/johndoe/magnolia/my-first-website-tutorial/light-modules
  3. Save the file.

  4. Start Magnolia:

    Mac OS X, Linux, Solaris
    ./magnolia_control.sh start
    Windows
    ./magnolia_control.bat start


Next: Creating a page template