Create Information Template Using Site Initializer

This blog will give step by step guide on how to create an information template for web content article for a specific structure using site initializer

Priyank Gajera
Priyank Gajera
2 Minute Read

Liferay's OOTB provides a great user interface that makes many complicated operations such as creating information templates so easy, but we still need to make good documentation on specific information templates as these templates can be used for web contents, products and objects. If we have more than one environment (DEV, UAT, PROD), we have to do this manual operation in each environment.

Well, In Liferay we have a way to automate it using site initializer client extension so that we don't have to do such operations again and again in different environments and this way we will not miss any steps during initial release.

For those who are new to site initializer, they can refer to the article at: https://liferay.dev/blogs/-/blogs/introducing-site-initializers

Using site initializer we can deliver initial contents (i.e. fragments, pages, categories/tags, structure, template and many more), which helps to deliver deliverables faster and no manual setup is required for initial site setup.

As we were working on one of the projects in past, we found it a little hard to create information template using site initializer.

We weren't facing a particularly difficult task, but we lacked the knowledge to complete it.

That's why I decided to create this blog - to serve as a quick reference for anyone encountering a similar situation in the future.

Before creating information template let’s create web content structure first and then I will show how to use this structure for information template

Under the site-initializer folder, create folder called “ddm-structures” if we don’t have that structure and create test-structure.xml file.

Then, populate this file with below content:

<?xml version="1.0"?>

<root>
<structure>
      <name>Test Structure</name>
      <description></description>
      <definition>
           <![CDATA[
              {
                "availableLanguageIds": [
                    "en_US"
                ],

                   "defaultLanguageId": "en_US",
                   "fields": [
                      {
                           "autocomplete": false,
                           "confirmationErrorMessage": {
                               "en_US": ""
                           },
                           "confirmationLabel": {
                               "en_US": ""
                           },
                           "dataSourceType": "",
                           "dataType": "string",
                           "ddmDataProviderInstanceId": "[]",
                           "ddmDataProviderInstanceOutput": "[]",
                           "direction": "[vertical]",
                           "displayStyle": "singleline",
                           "fieldNamespace": "",
                           "fieldReference": "title",
                           "hideField": false,
                           "indexType": "keyword",
                           "label": {
                               "en_US": "Title"
                           },
                           "labelAtStructureLevel": true,
                           "localizable": true,
                           "name": "title",
                           "nativeField": false,
                           "objectFieldName": "",
                           "placeholder": {
                               "en_US": ""
                           },
                           "predefinedValue": {
                               "en_US": ""
                           },
                           "readOnly": false,
                           "repeatable": false,
                           "requireConfirmation": false,
                           "required": false,
                           "requiredErrorMessage": {
                               "en_US": ""
                           },
                           "showLabel": true,
                           "tip": {
                               "en_US": ""
                           },
                           "tooltip": {
                               "en_US": ""
                           },
                           "type": "text",
                           "visibilityExpression": ""
                       },
                   ],
                   "successPage": {
                       "body": {},
                       "enabled": false,
                       "title": {}
                 }
               }
           ]]>
       </definition>
   </structure>
</root>

Here we have created a title field, one structure in the site-initializer folder.

If a folder named "ddm-templates" doesn't exist, create one.

Then, create a folder named "test-information-template" inside "ddm-templates".

Inside the "test-information-template" folder, create two files: 

  1. "ddm-template.ftl" 

  2. "ddm-template.json"

Populate these files with the content provided below (one file per content snippet).

ddm-template.ftl:

<#--
Add elements from the sidebar to define your template. Type "${" to use the
autocomplete feature.
-->
<#if (DDMStructure_title.getData())??>
   <h1>${DDMStructure_title.getData()}</h1>
</#if>

ddm-template.json:

{
   "className": "com.liferay.template.model.TemplateEntry",
   "ddmTemplateKey": "TEST-INFORMATION-TEMPLATE",
   "infoItemClassName": "com.liferay.journal.model.JournalArticle",
   "infoItemKey": "[$DDM_STRUCTURE_ID:TEST STRUCTURE$]",
   "name": "Test Information Template",
   "resourceClassName": "com.liferay.template.model.TemplateEntry"
}


Freemarker template file will hold markup and json file is configuration which is responsible to create this template programmatically.

Conclusion

Liferay DXP 7.4 recommends the client extension approach to create and update contents in Liferay. In the past we were able to create such templates using upgrade processes, but now we were able to create it with contents like information templates using site initializer CX with just a simple freemarker template and a json configuration file.

 

Page Comments

Related Assets...

No Results Found

More Blog Entries...

Ben Turner
October 21, 2025
Michael Wall
October 14, 2025