Skip to main content
Skip table of contents

Creating a Template

Before you create your first template you must set up a development environment - please have a look at the Workflow Overview documentation to see the process required for creating a template. The steps on this page will guide you through the process of creating a *.jar template app file that can then be uploaded and used in Confluence.

We've published an example template on Bitbucket that we recommend using as a starting point for new templates. You can browse it in our repository here:

The three main steps involved in the template creation process can be navigated to quickly here:

  1. Using the Scroll WebHelp Theme Example
  2. Customizing the Template
  3. Installing the Template

Using the Scroll WebHelp Theme Example 

Downloading the Scroll WebHelp Theme Template Files

If you are wanting to use the bundled Scroll WebHelp Theme as a base for your template creation you will either need to:

Naming your New Template App

Once you have the Scroll WebHelp Theme files, open the pom.xml file using your favourite text editor. This file contains the name and description of the app as well as build instruction for creating a proper app *.jar template file. You need to edit the top section in the file which looks like this:

<!-- The <parent> element should be completely removed when releasing your own plugin. -->

<!-- These should be adapted to match your company's domain and the name of the theme. -->
<name>Scroll WebHelp Theme</name>
<description>Provides the Scroll WebHelp Theme for Scroll Viewport and Scroll HTML Exporter.</description>

<!-- Add your organization's details here. -->
    <name>K15t Software GmbH</name>

<!-- Adapt this to point to your theme's remote git repository or remove it completely if you don't use a remote repository. -->
  • <groupId> contains the group of your plugin. This typically starts with the reverse URL domain name of your company to make it individual. At K15t we use something like com.k15t.scroll.templates
  • <artifactId> contains the actual ID of your plugin with it's group. This typically is a variation of the plugin name consisting only of letters ([a-zA-Z]), numbers ([0-9]) and dashes (-).
  • <version> contains the version of your template plugin. While still in development the version number usually ends with -SNAPSHOT. You can set that to whatever you want, e. 1.3.5-SNAPOT and 1.3.5 respectively for a version that should be used in production.
  • <name> and  <description> are displayed in the Plugin Manager. The name is just the name of the plugin, not the name of the template as displayed on the export dialog (more on that later).
  • <organization> contains the name and the URL of your company. This is also displayed in the Plugin Manager.

After you adapted the relevant sections in the file, you can save and close the file. Please note, the other parts of the file contain build information and must not be modified. Additionally, the specified Confluence version can be ignored as it is only required for building the template app file and doesn't need to match the Confluence version you are using.

Customizing the Template 

Next, you can start customizing the template. Typically you'll want to add some custom logos and CSS files to your template. You do that by adding so called static resources to the template. To do this open the file atlassian-plugin.xml in your favorite text editor. You'll find it in the src/main/resources directory.

Adding Static Resources

Static resources (e.g. logos, icon, CSS / JavaScript files) can be added to the template app *.jar file. For each static resource, define a <resource> element with type static-resource in the atlassian-plugin.xml file.

An example Static Resource definition: <resource type="static-resource" name="images/logos/icons/information.png" location="template/images/icons/accept.png" />

 This will make the file appear in the exported ZIP file.

  • namecontains the relative path where the file will be placed inside the exported ZIP file.
  • location - contains the relative path where the file is located in your template directory

In case of CSS / JavaScript files you'll also need to make sure a respective import <link> or <script> element is added to the exported HTML files. This is done by opening the file page.vm in a text editor. You'll find it in the src/main/resources/template directory. This file contains the top level HTML structure as well as Velocity placeholders where the actual Confluence content will be merged in. Add references to your CSS or JavaScript files here. You'll need to use the static resource names here.

Defining Velocity Templates (optional)

Should you require changes in the way the exporter generates HTML for the individual page elements like tables, notes and so on, you'll need to change some more Velocity files. If the default output is fine for your use case then you can simply ignore this section.

The Velocity templates are used by Scroll Exporters to output the Confluence contents to HTML. By modifying the templates the outputted HTML can be modified. With Velocity templates defined in the plugin you can overwrite the default velocity templates shipped with the exporter.

For each Velocity template that should be overwritten, define a resource element with type template-part in the atlassian-plugin.xml file.

An example Velocity Template definition: <resource type="template-part" name="page" location="template/page.vm" />

Building and Installing the New Template

After this your template is now to be built and then uploaded to Confluence. The new template will be installed as a Confluence app module in the Manage Apps section.

Building the *.jar file Template

  1. Install Atlassian SDK:
  2. Open Terminal (Linux/Mac) or Command Prompt (Windows) and navigate into the directory that contains the pom.xml file.
  3. Execute this command: atlas-package


    Don't worry if it takes quite some time to build. The Plugin SDK is based on maven which needs to download quite a few files when running for the first time. If you run atlas-package the next time it will be a lot faster. You can also automate the installation using the atlas-install-plugin command.

  4. After the packaging process for the build has been completed you will  find a new folder called target inside the current directory which contains the required *.jar template file.

Installing the Template in Confluence

Finally, you can upload the *.jar template file to Confluence via the Universal Plugin Manager (UPM) via the Manage Apps section in the Confluence administration. Any changes to the data in the pom.xml file (see step one) will then be visible in the expanded details for the template app in Confluence:

After the template *.jar file is uploaded you can select the template from the export dialogue when exporting - there will be an additional template available which is named according to what was defined in the pom.xml file.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.