Gantry 5: Directory and File Structure

/ web design, web development, gantry 5

In the previous article Introduction to Gantry 5: Installation and Configuration we saw how to install and configure Gantry in a very basic way, we also learned the basic concepts of this template development framework as well as its administration area.

This time we will learn about the file structure of our template, we will learn what each of the different Gantry 5 configuration files are for and how to change the name of our template by modifying several of the main files.


It contains several resources used in the Gantry 5 administration area, such as the thumbnail images of each of the presets in our template.

├── images
│   └── preset1.png
└── templates
 └── pages
 └── about
 └── about.html.twig


Includes configuration schematics for each template-specific style configuration section. By editing the files in this directory we can customize, for example, the controls that allow us to modify the color of the font and/or the background of the section.

In the following configuration file of the "header" section, TEMPLATE/blueprints/styles/header.yaml we can see an example:

name: Header Styles
description: Header section styles for the otherCode theme
type: section
      type: input.colorpicker
      label: Background
      default: "#3b3b3b"
      type: input.imagepicker
      label: Background Image
      default: 'gantry-media://header/pexels-photo-373076.jpeg'
      label: Background Overlay
      description: 'Enables the linear gradient overlay made of accent colors.'
      placeholder: 'Select...'
      default: enabled
        enabled: Enabled
        disabled: Disabled
      type: input.colorpicker
      label: Text
      default: "#ffffff"

The code we see above results in the following controls in the administration area:


Later we will delve into how to edit these files to add the features we want.

└── styles
 ├── accent.yaml
 ├── base.yaml
 ├── main.yaml
 ├── menu.yaml
 ├── navigation.yaml
 ├── offcanvas.yaml
 ├── showcase.yaml
 └── utility.yaml


It contains the presets.yaml file where the configuration of each of the template presets is stored.

It also contains the file theme.yaml, which is the main file of our template, by editing this file we can:

  • Change template metadata (name, version, author, platform, icon, etc.).
  • Change the style configuration groups of our template.
  • Add/remove custom fonts.
  • Add/remove block variations (css).
  • Modify scss compiler options.
├── presets.yaml
└── theme.yaml


This directory includes the base schemas in yaml format of each of the outlines that we will manage in the Oulines Manager (Layout Manager). Gantry has three system outlines, which are:

  • Body Only (_body_only.yaml): It is the schema that models the outlilne that loads only the main body part of our template.
  • Error (_error.yaml): This file is the one that controls the outline that will be loaded when the system experiences some type of error, such as a 404 page not found error.
  • Offline (_offline.yaml): In the same way that _error.yaml controls the outline that is displayed when the system experiences a failure, this file controls the outline that will be displayed when the system is offline.

In addition to these system outlines we can have as many outlines as we want, for example an outline for a blog view or an outline for the home view. Later we will create several custom outlines for our template.

├── blog.yaml
├── _body_only.yaml
├── default.yaml
├── _error.yaml
├── home.yaml
└── _offline.yaml


This will be a directory that we will use quite a bit since this is where we will store the particles that our template will use.

Each particle uses at least two files (particle.html.twig and particle.yaml), both of which are stored in this directory.

├── aboutme.html.twig
├── aboutme.yaml
├── sample.html.twig
└── sample.yaml


It contains the style files (scss) that are not specific to the platform, that is, it contains the styles of our template. This directory is divided, in turn, into several files and subdirectories.

For example:

├── configuration
├── template
│   ├── layouts
│   ├── particles
│   ├── sections
│   └── styles
└── template-joomla
 ├── components
 ├── particles
 └── styles


This directory is in all Joomla templates, it is here where the overrides of Joomla extensions are stored, whether they are content plugins, modules and/or components.

├── layouts
│   └── joomla
│       └── system
│           └── message.php
├── mod_simplecontactform
│   ├── default.php
│   └── horizontal.php
└── modules.php

Renaming the template

Now that we know what each of the directories is for, we can start developing our personalized template. The first thing we will do is change the name of the template g5_hydrogen, from there we can customize the template 100%.

As we already have a previous installation of the g5_hydrogen template that we use as a first contact with the framework, we should delete this installation or make a copy of this template to be able to perform the installation from scratch using the new name.

For this article we will make a copy of the template that we will call "HGWriter":

cp -r templates/g5_hydrogen templates/g5_hgwriter

We delete the files compiled with the previous references:

rm -rf templates/g5_hgwriter/custom/*

Now we must rename all the files that contain the term "hydrogen", for this we can use the following line in our terminal:

find templates/g5_hgwriter/ -name '*hydrogen*'


Once we have identified them we can go one by one renaming them or we can simply use the following command in our terminal:

for f in $(find templates/g5_hgwriter/ -name '*hydrogen*'); do mv ${f} ${f//hydrogen/hgwriter}; done

After executing this command we can verify that the files have been renamed correctly. It is time to change the content of the files that have any reference to the hydrogen template, the differences that we can find are:

  • Hydrogen
  • hydrogen

To perform this task quickly we will use the following lines:

for f in $(find templates/g5_hgwriter/ -type f -print0 | xargs -0 grep -m 1 -e "hydrogen" | cut -d ':' -f 1); do sed -i -e 's/hydrogen/hgwriter/g' ${f}; done
for f in $(find templates/g5_hgwriter/ -type f -print0 | xargs -0 grep -m 1 -e "Hydrogen" | cut -d ':' -f 1); do sed -i -e 's/Hydrogen/HGWriter/g' ${f}; done
for f in $(find templates/g5_hgwriter/ -type f -print0 | xargs -0 grep -m 1 -e "HYDROGEN" | cut -d ':' -f 1); do sed -i -e 's/HYDROGEN/HGWRITER/g' ${f}; done

It's time to change some meta-data of our template, editing the file templates/g5_hgwiter/templateDetails.xml.

<creationDate>December 14, 2018</creationDate>
<author>Unay Santisteban</author>
<copyright>(C) 2007 - 2019 otherCode. All rights reserved.</copyright>
<license> GNU/GPLv2</license>

We will change this data at will, for example, <author>, <authorUrl> and <authorEmail>, additionally we can change the url of the update server (if we have one) or we can simply delete said section :

    <server type="extension" priority="1" name="HGWriter Template"></server>

Now that we have changed all the files with the new name of our template we can install it in our Joomla, to do this we will go to Extensions > Manage > Discover:


Finally we select our template and import it by clicking the Install button.

Ready! We already have our custom template installed in our Joomla!

If you have any problems during the installation you may have to change the permissions or the owner of the template directory.

Next Post Previous Post