Our blog

Stay up to date with our news!

Create a Moodle Child Theme

Create a Moodle Child Theme

Here is the video of the presentation our colleague Roser gave the other day at our offices on how to create a Moodle child theme.

In this workshop we’ll learn what a child theme is and why it matters for developing and customizing any Moodle site, especially its look and feel. We’ll explain what kinds of customizations a child theme allows and touch on the basics of inheritance from the parent theme. Finally, a short hands-on workshop will show how to create a child theme of the Classic theme.

A Moodle child theme is a custom theme that inherits styles, templates, layouts and renderers from a parent theme, usually Boost, and contains only the changes you want to make. It lets you customize Moodle’s appearance without touching the original theme’s code, so you can update Moodle and the parent theme without losing your customizations.

  • What it is: a theme-type plugin that declares another theme as its parent in its config.php.
  • What it’s for: changing colors, login, header, footer, front page, icons or activity views without building a theme from scratch.
  • Minimum files: version.php, config.php, lib.php, language files and the favicon and screenshot images.
  • Four techniques: stylesheets, Mustache templates, layouts and renderers, from least to most complex.

What a Moodle child theme is

A child theme is a Moodle theme that depends on another one. When you create it, it’s almost an empty shell: it inherits the parent’s styles, templates, page layouts, icon system and part of its configuration, so when you activate it the platform looks practically the same. From there, you only add the files that change something.

Since it’s a plugin in its own right, the child theme has its own language strings and can have its own settings, although at first it has none. It’s used when the parent theme falls short on some requirement and you want to make specific customizations while letting the parent handle everything else.

Why use a child theme instead of modifying the theme or building your own

There are three ways to change Moodle’s appearance, and only one combines flexibility with safe updates:

OptionInitial costUpdatesMaintenance
Editing the parent theme directlyVery lowEvery update wipes out your changesHigh and unpredictable
Child themeLow to mediumThe parent updates on its own; you review your overridden filesProportional to what you override
Custom theme from scratchVery highEverything is up to youHigh: you maintain the whole theme

Conclusion: a child theme separates the core code from your modifications, which is good development practice, and avoids touching the Moodle core and the theme itself. A small amount of style and structure code delivers a lot of visual value.

What you can customize with a Moodle child theme

With a child theme you can change almost all of Moodle’s visual layer. The most requested customizations are:

  • Login page: custom background, colors and text, such as the contact email or legal notice.
  • Activity icons: replacing the images with ones that match the brand’s visual style; the change applies across the whole platform.
  • Header, footer and menus: custom logos, text, links and icons.
  • Front page: sliders, featured blocks, videos or course categories with different designs.
  • General styles: typography, colors, buttons, cards and borders.
  • Activity views: for example, a quiz redesigned to be more pleasant during long sessions.

In 3ipunt projects, child themes have been used for everything from branded login pages to front pages with sliders and course categories with different formats and enrollment methods, or a completely redesigned quiz. When the front page needs a lot of dynamic data, the child theme is combined with additional development.

What a child theme inherits from its parent theme

A child theme inherits six elements from its parent:

  • Styles: the parent’s compiled CSS or SCSS.
  • Mustache templates: the HTML structure of each component.
  • Layouts: the PHP files that prepare the data for each page type.
  • Icon system: the icons for activities, plugins and navigation.
  • Renderers: the classes that generate the output of Moodle and its components.
  • Part of the configuration: not all of it; settings the administrator set on the parent, such as Boost’s brand color, don’t automatically apply to the child.

If you want the child to respect those parent settings or to chain configurations (child, parent, grandparent), you need to code more advanced inheritance in lib.php. It’s possible, but every link in the chain adds maintenance.

Minimum structure of a Boost child theme

A working child theme needs these files inside theme/[name]. In Moodle 5.1 and later, plugins live inside the public/ folder, so the path is public/theme/[name].

File or folderRequiredWhat it’s for
version.phpYesPlugin version, minimum Moodle version, component and parent theme dependency
config.phpYesTheme name, parent theme, stylesheets and renderer factory
lib.phpYes (can be empty)Moodle callbacks: SCSS, navigation, advanced inheritance
lang/xx/theme_[name].phpYesTheme strings in each language
pix/favicon.ico and pix/screenshot.pngYesBrowser tab icon and theme selector image
style/ or scss/NoCustom styles
templates/NoOverridden or new Mustache templates
layout/NoOverridden layouts
classes/output/ or renderers.phpNoOverridden renderers

How to create a Boost child theme step by step

Creating a basic Boost child theme takes less than an hour if you follow this order:

  1. Choose the short name: lowercase only and no spaces, for example myboost. It will be the folder name, the component identifier (theme_myboost) and the value of $THEME->name; all three must match.
  2. Create the folder theme/myboost (or public/theme/myboost in Moodle 5.1+).
  3. Create version.php with the Boost dependency. Copy the value of $plugin->version from the Boost version.php in your installation.
  4. Add the language files in lang/en/theme_myboost.php (and in every language you need) with at least pluginname, choosereadme and configtitle.
  5. Create config.php declaring Boost as the parent.
  6. Create lib.php, even if it stays empty for now.
  7. Add pix/favicon.ico and pix/screenshot.png; at first you can reuse Boost’s screenshot.
  8. Install the theme from Site administration → Notifications and select it under Appearance → Themes.

A minimal version.php looks like this (the numbers are examples):

<?php
defined('MOODLE_INTERNAL') || die();

$plugin->version = 2026112400;
$plugin->requires = 2025100600; // Minimum Moodle version.
$plugin->component = 'theme_myboost';
$plugin->dependencies = [
'theme_boost' => 2025100600, // Boost version in your installation.
];

And a basic config.php:

<?php
defined('MOODLE_INTERNAL') || die();

$THEME->name = 'myboost';
$THEME->parents = ['boost'];
$THEME->sheets = ['custom']; // Loads style/custom.css.
$THEME->editor_sheets = [];
$THEME->yuicssmodules = [];
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
$THEME->requiredblocks = '';
$THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV;
$THEME->hidefromselector = false;

Each line has a specific purpose:

  • parents: the most important line. Without it, the theme is an empty shell that inherits nothing. It accepts several parents: a Classic child needs ['boost', 'classic'], because Classic uses layouts from both.
  • rendererfactory: allows your renderers to replace Moodle’s.
  • hidefromselector: if you set it to true, the theme no longer appears in the site, category and course selectors. It’s useful for pulling it temporarily if you spot a problem in production.

Before signing off on the theme, compare your config.php with Boost’s for your version: Moodle 4.x added settings such as haseditswitch or usescourseindex that are worth reviewing.

Shortcut: 3ipunt’s child theme template

We’ve published the boostchildtemplate on GitHub with all the minimum files. To use it, you only need three changes:

  1. Find and replace NAME with the theme’s display name and PACKAGECODE with the short name.
  2. Rename the language files to theme_[short name].php in each lang folder.
  3. Check that the theme folder has the same name as the short name.

The template was created for Moodle 3.8: update the numbers in version.php and review config.php before using it on a current version.

How to customize the child theme: styles, templates, layouts and renderers

With these four techniques you can change almost any part of Moodle without touching core code. The golden rule is to always use the parent theme as a reference: anything the parent does, the child can do too by replicating the same folder structure.

How to add your own styles

Create a style/ folder in the child theme, add a file such as custom.css and include it in $THEME->sheets without the extension. Moodle loads it on every page where the theme is active. For projects with lots of styles, it’s better to work with SCSS through the lib.php callbacks, which lets you use Bootstrap variables and keep Boost’s brand settings.

Moodle caches themes. While you develop, turn on theme designer mode or purge the caches after each change, and don’t leave designer mode on in production because it slows the platform down.

How to override a Mustache template

To change a component’s HTML, copy its template into the child theme inside a folder named after the source component: templates/theme_boost/ for Boost templates, templates/core/ for core templates or templates/mod_quiz/ for quiz templates.

For example, to modify Boost’s main layout in Moodle 4.x and 5.x, copy theme/boost/templates/drawers.mustache to theme/myboost/templates/theme_boost/drawers.mustache and edit the copy. If you put the file directly in templates/, without the component folder, Moodle will keep using the parent’s.

The theme’s own templates, which don’t override anything, go directly inside templates/.

How to pass data to a template with a layout

Templates only display the data they receive. To pass a new piece of data, such as a text from the settings or the site name, copy the corresponding Boost layout (for example, layout/drawers.php) to your theme’s layout/ folder and add the variable to $templatecontext. Unlike templates, layouts don’t need the component subfolder: Moodle looks in the active theme first.

Keep the scope in mind: the drawers layout is used on almost every Moodle page (course, activities, administration, front page). A change there will show up across the whole platform. To limit it to the front page, pass a variable to the context that indicates the page type and use a condition in the template.

How to override a renderer

When the change affects a specific area generated by PHP, the most precise option is to override the renderer that draws it. You create a class in the child theme that extends the original renderer, with the prefix theme_[name]_ (or in classes/output/ with the theme’s namespace), and copy into it only the method you want to change.

<?php
defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/course/renderer.php');

class theme_myboost_core_course_renderer extends core_course_renderer {
// Copy here the method that draws the area you want to change
// and modify its output.
}

The hard part is finding the exact method that generates what you see, but the result only affects that output and not every page.

TechniqueWhat it changesScopeDifficulty
StylesheetVisual appearanceThe selectors you defineLow
Mustache templateStatic HTML structureEverything that uses that templateLow to medium
LayoutData passed to the templateEvery page using that layoutMedium
RendererOutput generated by PHPOnly the overridden methodMedium to high

How to maintain a child theme when Moodle is updated

The advantage of a child theme is that the parent can be updated safely. The catch is that you maintain your child theme, and the work is proportional to what you’ve overridden. With each update, it’s worth following four steps:

  1. Compare each overridden file (templates, layouts, renderers) with its new version in the parent. If the original has changed a lot, start from the new version and reapply your snippets.
  2. Review the CSS classes your styles use. Moodle 5.0 upgraded Bootstrap to version 5, and some Bootstrap 4 classes changed.
  3. Update the dependency in version.php to the parent version you’ve tested. That way you’ll know which combination works if something breaks.
  4. Keep a stable version of the theme before adapting the next one.

Major jumps, such as the move from Moodle 3.x to 4.0, when Boost replaced columns2 with drawers, force you to redo layout overrides. If you need to plan one of these upgrades, our experience upgrading to Moodle 4 without downtime and our overview of what’s new in Moodle 5.3 may help.

The same applies to themes that already inherit from Boost, such as Adaptable: you can create a child of them by setting that theme as the parent and its version as the dependency. Each level in the chain is one more theme to review when updating.

A child theme can also patch the parent

At the 3ipunt workshop, Roser Pruaño explained a lesser-known use. When a third-party parent theme had a bug in its icons, the team fixed it in the child theme by overriding only the affected part. The platform worked fine while the author released the fix, without touching their code or blocking their updates. In other projects they’ve even chained inheritance three or four levels deep to apply different styles by course, category or site. The takeaway: a child theme is also a reversible patch layer, as long as you document what it fixes and remove it once the parent solves the issue.

Common mistakes when creating a Moodle child theme

  • Folder and name that don’t match: if the folder, $THEME->name and the component in version.php aren’t identical, Moodle doesn’t detect the theme or throws an error on install.
  • Wrongly named language files: they must be called theme_[name].php in every language folder.
  • Overridden template without the component folder: Moodle keeps using the parent’s and the change seems not to work.
  • Editing the parent theme “just to test”: the change will be lost in the next update. Always test in the child.
  • Not purging caches: style changes don’t appear until you clear the cache or turn on theme designer mode.
  • Expecting the child to inherit the parent’s settings: colors or images configured in Boost don’t carry over to the child without configuration inheritance.
  • Copying the Boost recipe for a Classic child: Classic needs its own steps and must inherit from both Boost and Classic.

How to customize your Moodle without starting from scratch

A child theme is the foundation of any serious Moodle customization, but designing and maintaining it takes development time. If you’d rather have a ready-to-use solution, the Fresk Suite for Moodle and Workplace offers an adaptable visual design without coding. If your project needs a custom theme, the 3ipunt custom development team designs and maintains it; we also offer technical support for Moodle. Tell us what you need.

Frequently asked questions about Moodle child themes

What’s the difference between a theme and a child theme in Moodle?

A full theme defines its own styles, templates, layouts and renderers. A child theme contains only the changes and inherits the rest from a parent theme declared in config.php. That’s why it’s quicker to create and easier to maintain when updating.

Which theme should the child theme be based on?

Boost is the most common choice because it’s Moodle’s default theme, it’s updated with every release and it’s well documented. You can also inherit from a third-party Boost-based theme if it’s actively maintained; the more stable the parent, the less work you’ll have with each update.

Do I lose my child theme when I update Moodle?

No, the child theme is an independent plugin and it’s kept. What can happen is that a template, layout or renderer you’ve overridden no longer matches the parent’s new version. That’s why it’s worth reviewing overridden files and testing in a staging environment before updating production.

Do I need to know how to code to create a child theme?

For a child theme with custom styles, knowing CSS and following the file structure is enough. To override templates you need HTML and Mustache; for layouts and renderers, PHP and knowledge of Moodle’s architecture. If you don’t have that profile, there are visual no-code alternatives.

Can I create a child theme of another child theme?

Yes, Moodle lets you chain inheritance, for example Boost, an intermediate theme and your theme. You need to declare the direct parent in config.php and its version in the dependencies. Each level adds a theme to review when updating, so it’s best not to lengthen the chain unnecessarily.

How do I temporarily hide a child theme that has errors?

Set $THEME->hidefromselector = true; in its config.php and purge the caches. The theme no longer appears in the site, category and course selectors, so nobody can activate it while you fix it.

Share this post!
Scroll to Top