When Moodle template overrides in a theme are the right fix
If you need to change Moodle's markup on a self-hosted site without editing core, the mechanism is a set of Mustache template overrides, renderer overrides and icon overrides placed inside a theme. This section helps you decide whether that work is the right fix before anyone writes a line of code. Teams usually reach for it for three reasons: a branded page layout that the settings screens cannot produce, an accessibility markup fix such as a missing label or a heading order problem that a stylesheet cannot repair, or a need to replace what a block or a core output prints. Each of these changes the HTML itself, which is why a styling change alone is not enough.
Before committing to overrides, check the lighter options first. A Boost child theme that uses theme settings, logos, colours and SCSS will cover most branding requests, and it keeps your changes in one place. Behaviour changes, new pages, scheduled jobs or extra settings belong in a local plugin, not in a theme, because a template override only alters presentation. If the request changes what data is shown or who can see it, a template override is the wrong layer. Ask your Moodle partner or internal lead to classify every requested change as styling, markup or behaviour before estimating effort, since that classification sets the size of the work and the upgrade exposure.
Every overridden template is a copy of core markup you now own. When Moodle HQ changes that template in a later release, your override will not pick up the change automatically, so the site can drift from core behaviour or lose a fix. Plan a register of overridden templates and renderers, record the Moodle version each was copied from, and run a comparison against the new release notes and the code before every upgrade. Confirm with your release process how long that review is expected to take for the versions you plan to run, and check the exact target versions against the Moodle releases page and the upgrade requirements for each release.
Template, renderer and icon overrides compared
A template override replaces the Mustache template that Moodle renders for a specific piece of markup. You place a copy of the core template in your theme at the same relative path under the theme's templates folder, then edit the copy. Moodle looks for the theme's version first and falls back to core when none exists, so the change stays inside the theme and the core files are untouched. This is the most common choice for adjusting the layout of a block, a navigation element or a form section.
- Where it lives: a
templatesfolder inside the custom theme, mirroring the core path of the template being changed. - What it changes: only the markup of that one template. Logic that prepares the data stays in PHP and is not affected.
- Maintenance cost: every overridden template is a copy of core, so each Moodle upgrade may change the source you copied and require a manual merge.
- Typical mistake: copying a template from the wrong version, or copying a large template to change one line, which makes later merges expensive.
- Keep the list short: each extra copy is another file to review at every upgrade.
Before relying on a template path, confirm it exists in the Moodle version you run, because templates move between releases. Check the override list after each upgrade.
A renderer override changes the PHP class that builds the output for a component, not just its markup. Moodle components expose renderer classes, and a theme can provide a subclass that overrides specific methods so the data is prepared differently before it reaches a template. Use this when the change depends on logic, such as altering which items appear or how values are grouped, rather than on layout alone.
- Where it lives: a renderer class inside the theme, named and placed according to Moodle's renderer lookup rules for the target component.
- What it changes: the methods you override and the data passed to templates, which can affect many pages that call the same renderer.
- Maintenance cost: you depend on method signatures in core. A signature change in an upgrade can break the theme with a fatal error rather than a visual glitch.
- Typical mistake: overriding a broad method when only one output branch needs to change, so unrelated pages are affected.
- Test coverage: exercise every page that uses the renderer, not only the one you intended to change.
Class names and method names must be confirmed against the Moodle version in use, since renderer structure changes between releases. Prefer a template override when the change is only markup, because it carries less upgrade risk.
An icon override changes which icon appears for a named action or element without editing the templates that display it. Moodle maps icon identifiers to image or font resources through a theme-level mapping, so every place that uses an identifier picks up the new icon. This is the lightest of the three mechanisms and suits brand-consistent icon sets or accessibility-driven replacements.
- Where it lives: the icon mapping defined by the theme, which points an identifier to a replacement icon file or font glyph.
- What it changes: the icon shown wherever that identifier is used, across all templates and plugins that reference it.
- Maintenance cost: low, because the mapping is small, but plugins that hard-code their own icons will not follow the change.
- Typical mistake: replacing an icon that carries meaning for screen reader users or that the theme's accessibility checks depend on, without a text label.
- Visual review: check each replaced icon at the sizes and contexts where it appears, including dark or high-contrast settings.
Confirm the identifier names and mapping format against the Moodle version in use, because both have changed across releases. Test the icon set on the mobile app if your users rely on it.
How to build a template override in a theme
This sequence takes a template change from a stated goal to a verified override in a child theme, so the markup changes without any edit to Moodle core. Each step ends with a check that the override is loaded and the page still works.
Confirm the target Moodle version and theme base
The team records the exact Moodle version in production and the theme the site uses, usually a child of Boost or another parent theme. Template paths and variables change between releases, so the copy must come from the same version that runs in production. Confirm the version under Site administration, then check the theme's parent setting in the theme configuration. The step is done when the version number and parent theme are written into the change ticket and both match the staging copy of the site.
Locate the core template and its render context
Find the Mustache template in the Moodle codebase for the version in use, typically under a component's templates folder, and open the renderer or class that calls it. Read which context variables the template expects and which page identifiers or CSS hooks the surrounding page depends on. Record these in the ticket as the list of things the override must keep. The step is done when the team can name the template file, the calling code, and every variable it receives.
Copy the template to the matching path in the theme
Copy the core template into the theme's templates folder, keeping the same relative path under the component name, so the file sits where Moodle's theme lookup expects it. Edit only the markup needed for the goal and leave variable names, IDs and required classes untouched. Keep the change small so later diffs against core stay readable. The step is done when the file path mirrors the core path and the diff against the original shows only the intended markup changes.
Clear caches and confirm the override loads
Purge all caches from the administration interface, or with the CLI purge command in the Moodle installation, so the theme's template list is rebuilt. Then load a page that renders the template and confirm the new markup appears. If nothing changes, check that the theme is the active theme for that context, that the file path matches exactly, and that the cache purge ran on the same server that serves users. The step is done when the changed markup is visible on the affected page and the core version is still unchanged.
Check required identifiers and template variables
Compare the rendered page with the page before the change. Confirm that required page identifiers, body classes used by Moodle JavaScript, form field names and every context variable still appear and still feed the same behaviour. Test a form submission or interactive control on the page to confirm the JavaScript still works. The step is done when the checklist from the context review is ticked and no required hook has been dropped.
Verify the change on affected pages and roles
Test the override on every page and user role that renders the template, including students, teachers and administrators, and on the mobile or narrow layout if the site uses it. Check the page in the browser console for new JavaScript errors and confirm that accessibility labels and keyboard navigation still work. Record results against the list of affected pages. The step is done when each affected page and role passes and the results are stored with the change record.
Record the override and track it through upgrades
Log the override in the theme's documentation with the core template path, the Moodle version it was copied from, the reason for the change and the variables it relies on. Add the template to the list the team reviews before each upgrade, so that changes in core are compared against the copy. The step is done when the record exists, is linked from the change ticket, and names the owner who will review it at the next upgrade.
How Moodle resolves a template from core to theme
The diagram starts when a page calls a renderer for a Mustache template, such as a block or a navigation fragment. Moodle walks the theme chain from the current theme through its parent themes and then to core, and the first matching file on that path wins. Check two things: that the override sits at the same relative path as the core template it replaces, and that the cache is purged after the change, because a stale compiled template can hide your edit. An upgrade can change the core file that your copied override was based on, so the override needs to be reviewed against the new core version.
Template lookup order from the current theme through core, with the cache and upgrade points marked.
How to track overridden templates when core changes in an upgrade
Every overridden template is a copy of core markup that stops updating on its own. The practices below keep those copies visible, reviewed and tested so that each Moodle upgrade shows what changed and who must act on it.
Keep a register of overrides
List every overridden file in the theme with the path of the core template it replaces and the core version it was copied from. Store the register in the theme repository next to the code, so it is reviewed with each change. Without this record, a later upgrade cannot tell an intentional override from a copy someone forgot to remove.
Diff copies against new core
During each upgrade, compare every copied template with the new core version of the same file. Look for changed variables, added context data, altered ids and changed classes. A clean diff on the copied file is not enough: the new core markup must still be merged into the copy wherever it changed.
Run automated checks in staging
Add scripted checks to the staging pipeline that flag overridden templates whose core source has changed, and that fail when a required page id or region is missing from rendered output. Run them against a copy of production data before any production change. Checks catch drift that a manual review may miss in a large theme.
Limit the number of overrides
Each override adds upgrade work, so override only the markup that the design cannot reach through settings, presets or SCSS. Before copying a template, check whether a Boost setting, a custom CSS rule or a language string already achieves the goal. Fewer overrides means fewer files to diff at each upgrade.
Record an owner for each override
Name a person or team responsible for each overridden template, and record the reason the override exists. When core changes, the owner decides whether to merge, remove or keep the copy. Unowned overrides tend to persist after the business need has passed, and nobody is left to answer questions during an upgrade.
Plan a retest before production
Before promoting an upgraded theme, retest every page that renders an overridden template, including course pages, the dashboard, forms and mobile output where used. Confirm the results against the register and record the outcome. Ask your partner or internal team to confirm the test scope in writing before the upgrade starts.
Configuration and override options and when each fits
This table compares the five ways a team can change Moodle's look or markup, from settings in a Boost child theme to a local plugin for behaviour. Read each row as a ladder: the options higher up change less of core's output and usually cost less to keep working across upgrades. The main takeaway is to start with settings and template overrides, and reserve renderer overrides and plugins for changes those cannot reach.
| Option | What it changes | Upgrade exposure | Testing effort | When to pick it |
|---|---|---|---|---|
| Boost child theme settings | Colours, logos, fonts and some layout options through theme settings and presets | Low, since settings live in the theme configuration rather than in copied code | Light: visual checks on key page types after each upgrade | Branding and layout changes that the theme settings already expose |
| Template override | Markup of one Mustache template, selected by its component and path inside the theme | Medium: the copied template can drift when core changes that template in a release | Moderate: check every page that renders the overridden template, on each upgrade | Markup changes confined to a known template, such as a block, navigation element or course listing |
| Renderer override | Output produced by a PHP renderer class for a component, including logic that builds the data passed to templates | Higher: renderer methods change more often than templates and can break on signature changes | Higher: test the renderer's methods and every page that calls them | When the change needs PHP logic that a template alone cannot express, and a template override is not enough |
| Icon override | Which icon image or font glyph Moodle uses for a given icon identifier | Low to medium: depends on whether the icon map changes in core | Light: check the icons on the screens where they appear | Swapping icon sets for brand consistency without changing any markup |
| Local plugin for behaviour | Server-side behaviour such as event observers, scheduled tasks, admin settings and added pages, without changing output | Low to medium: depends on the core APIs used and on the plugin's own maintenance | Moderate to high: test the new behaviour and its interaction with core workflows | When the requirement is about what the system does, not how a page looks |
Security and operational considerations for theme overrides
Every overridden template changes markup that Moodle users, administrators and assistive technologies rely on. The cards below are checks to run before a theme override reaches production, and each one connects to how the override is written, reviewed, deployed and maintained.
Output escaping and unsafe HTML
Mustache escapes variables by default when they are written with double braces, but triple braces and helper output can insert raw HTML. Review every override for {{{ }}} tags and for any variable that carries user-supplied text such as course names, forum posts or profile fields. Confirm that each unescaped value comes from a source Moodle has already cleaned, and test an override with a course name containing markup characters before release.
JavaScript added through templates
Inline script tags or event handler attributes placed in a template bypass the review you would apply to a theme JavaScript file, and they can conflict with Moodle's content security settings. Keep behaviour in AMD modules loaded through the page's JavaScript calls, and search overridden templates for <script and on attributes. Confirm the page still works with the browser console open and no errors on the pages you changed.
Accessibility regressions
Core templates carry ARIA roles, labels, heading levels and focus behaviour that screen reader users depend on. A rewritten template can drop an attribute or change the element order without any visible sign. Compare the rendered output of the overridden template with the core version using an accessibility checker, and test keyboard navigation through the changed page before each release.
Data exposure through new variables
When a renderer passes extra data into a template, that data becomes available to anyone who can edit the template and can leak into markup for users who lack the capability to see it. Check that every new variable is built from data the current user is allowed to see, and that renderers apply the same capability checks as the core code they replace. Review the rendered HTML for a user with a restricted role.
Deployment control of theme code
Overrides live in the theme directory, so anyone who can change files on the server can change what every user sees. Keep theme code in version control, deploy it from a reviewed build rather than by editing files on the live server, and record which commit is running. Confirm who may approve theme changes and who may access the server, and keep the record of approvals with the change.
Cache handling after changes
Moodle caches compiled templates, theme CSS and JavaScript, so an edited override may not appear, or may appear for some users and not others, until the caches are purged. After each deployment, purge the theme caches and confirm the change on a page that users access through different roles. Include the cache purge as a step in the release runbook so it is not left to chance.
Questions buyers ask about Moodle template overrides
What drives the cost of overriding Moodle templates in a theme?
The cost depends mostly on how many templates and renderers change, how far the new markup departs from core, and how much of the page set must be verified afterward. A few overrides to a single block are a small job. Overriding course, grade or dashboard markup across several page types takes longer because each page needs its own review in each supported browser and role. Ask any partner for a quote built from a written list of templates, renderers and icons, with the pages and roles that must be tested. Setup is one-time work, while later upgrade reviews recur with each Moodle release you adopt.
How long does it take to test a set of template overrides?
No duration can be given without the list of overrides, so treat any quoted timeline as provisional until the scope is written. The main drivers are the number of templates and renderers, the number of page types they affect, the roles that see those pages, and whether a test site with a copy of your data exists. Overrides that touch forms, navigation or accessibility markup need more review than purely visual changes. Ask for the test matrix as part of the quote, so you can see which pages and roles are covered before work starts.
What does the client team need to provide for template override work?
The work needs a test environment that matches production closely enough to show real page output, plus named people who can approve results. Your team should provide access to the theme code repository, a list of pages and roles that matter most to users, and any accessibility or branding rules that markup must meet. Someone who knows your site configuration should confirm which plugins alter the same pages, since overrides can conflict with them. Decisions about which markup you want to keep and which you accept from core also need an owner before the build starts.
Can an internal team build and maintain Moodle template overrides?
Yes, if the team has PHP, Moodle's Mustache template language and the Moodle theme structure in its skills, and if it can test changes against real course and role data. Overrides are normal theme work, and many in-house teams maintain them. The harder part is ongoing: someone must track each overridden file each time Moodle changes it, then retest the affected pages. Teams without that routine often find overrides quietly drift out of date. A partner can take on the initial build and document the override register, leaving your team to run the upgrade checks.
How do Moodle upgrades affect template overrides?
An override replaces a core template file at a given path, so when core changes that file in a later release, your copy keeps the old markup and does not receive the fix or the new structure. The override can then break a page, hide a new feature element or create an accessibility gap without any error message. Plan for it by keeping a register of every overridden template and renderer, recording the core version it was copied from, and reviewing each entry against the release notes before you upgrade. Moodle 5.1 release notes and each later release notes page should be checked for template and renderer changes.
Which Moodle version and server requirements should I check before testing overrides?
Confirm the target Moodle version first, because the server requirements and the document root change between releases. From Moodle 5.1, the web server document root must point to the new /public directory rather than the main Moodle folder, and Moodle 5.1 requires 64-bit PHP 8.2 or later. Moodle 5.3 requires 64-bit PHP 8.3 or later and removes the Classic theme from core, so a theme that depends on Classic must be rebuilt. Test overrides on the exact version you plan to run, not an earlier one.
When should I use a local plugin instead of overriding a template?
Use a local plugin when the change adds behavior, such as an event observer, a scheduled task, an admin setting or a new page, rather than only changing how existing markup looks. Template overrides are best for presentation changes to core output. If the change needs business logic, data from another system or settings your administrators manage, a local plugin keeps that code separate from the theme and easier to test. Many projects use both: the theme holds markup and styling, and a local plugin holds the logic. Choose the route that keeps each upgrade review small.
How DeployOpen scopes override work on Moodle
DeployOpen scopes a template and renderer override job as a fixed-scope engagement, with the scope agreed in writing before any code changes. The written scope lists each Mustache template and renderer method being overridden, the theme or local plugin that carries it, the Moodle version it was written against, and the pages or user journeys that must look and behave correctly afterwards. Icon overrides, custom template paths and any renderer subclasses are listed separately so the reader can see the full footprint. Before quoting, confirm with your team which core templates your designers actually need to change, because a short, named list keeps both the build and the later upgrade review small. The quote follows from that written scope, and DeployOpen does not publish a price list.
Every override is documented in a register that records the core file path, the overriding file path, the Moodle version it was copied from, the reason for the change and the owner. Each entry is tied to a test case in a staging environment that mirrors your production Moodle, PHP and database versions, and the override is accepted only when those cases pass. DeployOpen deploys and tests the build in infrastructure you control, so staging and production share the same configuration and the evidence stays with you. Ask for the register format and the staging test list as part of the deliverables, since they are what your team will use when a core template changes in a later release.
Retainer support covers the work that follows the build: reviewing the override register against each Moodle release, checking changed templates before an upgrade reaches production, and retesting after fixes. Because the register already maps each override to its source version, the review can focus on templates that core has changed rather than the whole theme. Retainers are available for ongoing support, upgrades and continuous testing, and the reader should confirm the review cadence, the response expectations and which Moodle releases are in scope before signing. Nothing in this section is a promise about outcomes for any particular site.
How DeployOpen delivers Moodle theme work
DeployOpen scopes template and renderer overrides in writing before any code changes, then builds them inside a child theme so Moodle core stays untouched. Each overridden template is recorded, tested against the Moodle version in use, and handed over with the steps your team needs to review it at upgrade time.
How we scope
- The written scope lists which templates, renderers and icons are changing and why each one needs an override.
- We confirm the target Moodle version and the theme base, such as Boost or a child theme already in use.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
How we build
- Overrides are placed in the theme by path and kept as small as the requirement allows.
- Renderer and icon overrides are added only where a template alone cannot achieve the markup change.
- Each overridden file is tested on the pages it affects, including accessibility checks on changed markup.
How we hand over
- You receive a register of every overridden template, renderer and icon, with the core file it replaces.
- Documentation explains how to diff each override against core when a new Moodle release ships.
- Your team walks through the code and the upgrade checklist before the engagement closes.
How we support
- Ongoing support and upgrades can be taken on as a retainer after the initial delivery.
- Retainer work covers re-checking overrides against each new Moodle release and retesting affected pages.
- Confirm with us during scoping which Moodle minor releases and upgrade windows the support covers.

