Web design, CMS and development, since 2014VR Games
Joomla

The Power of Joomla Template Overrides: Why They Trump Editing Core Files

If you are a Joomla builder, you may have wanted to modify the way articles, Category Blog items, or modules are displayed on your site. Joomla provides a secure way to change output safely: by placing template override files in the active template’s html folder, which Joomla loads in place of the original core files. This beautifully avoids any complications when updating core and extension content.

What a Joomla Template Override Is (And Where It Lives)

A Joomla template override is a copy of a core layout file placed in the active template structure. For instance, Joomla stores override files under the active template directory: /templates/[template_name]/html/ for templates like rhuk_milkyway, JA Purity and Beez.

Example Joomla Template Override folder layout `` /templates/rhuk_milkyway/html/. /templates/ja_purity/html/. /templates/beez/html/. ``

An override is "a file or database entry that is loaded instead of the normal core file," states a technical guide. It is "nearly always placed inside your template’s files," somewhat similar to child themes in WordPress.

A simple override hierarchy diagram

When modifying output, Joomla uses presentation files stored under the active site template’s html directory which identify the extension and layout they replace. They have a directory structure like TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php.

A Joomla template override allows changing the HTML and PHP used for component, module, or reusable layout views without editing the component or module source file.

How Joomla Chooses Overrides Over Core Files

Joomla will use an override if it matches the path under the template’s html directory. For instance, when it encounters a template component file, it looks for a matching override path.

When overriding template files, a file at yoursite/components/com_component/tmpl/view/template.php' is copied to your active template: yourtemplate/html/com_component/view/template.php. When overriding a layout, yoursite/layouts/pathtolayout/layout.php is copied to: yourtemplate/html/layouts/pathtolayout/layout.php`.

The structure to override a component view layout within a template is: /templates/template_name/html/com_component_name/view_name/layout_name.php

This maps to a location like: /con_uikit/html/com_contact/contact/default.php

When Joomla needs to render this view, it checks for an override in the template html directory first, since they get precedence over the core layouts.

Creating Overrides Safely via the Joomla Admin

You do not need to manually copy files or even know this directory structure. Template override paths are generated from the Joomla Administrator interface. With a published template, navigate to: System → Templates → Site Templates, and select the template. On the right side, click on the Create Overrides tab.

Choose an extension (e.g. Content), view (e.g. Category), and layout (e.g. Blog). This action copies all relevant view files into the template folder. You just need to modify and save the copies.

The Joomla! Community Magazine article on managing template overrides shows a concrete example. Selecting the category view of com_content for a blog layout from the Template Manager triggers Joomla to copy all related files into the template's html directory, then just edit the specific needed files such as `blog_item.php' to customize the output.

Why Editing Core Files Breaks Updates (And Overrides Don’t)

Although you can directly edit core files, this is not recommended, because those edits will be overwritten during updates. If you make your changes in the HTML and PHP used by an extension, you will have to redo the changes after each update.

This is why Joomla implementers and developers follow the Overrides design pattern: you copy the files to be overridden to the active template folder, and simply edit the copy.

The main benefit is that component or core upgrades will not overwrite the layout overrides inside the template’s html directory, because Joomla loads the override instead of the updated core layout file.

Special Cases: Layout Overrides and Child Templates

Template overrides are not limited to components. You can also override generic layout files.

Any layout file located at /components/COMPONENT_NAME/layouts/FOLDER_NAME/LAYOUT_NAME.php can be overridden by uploading it to the template overrides folder at /YOUR_TEMPLATE/html/layouts/COMPONENT_NAME/FOLDER_NAME/LAYOUT_NAME.php.

Child templates in Joomla 4 inherit the same logic. When you create an override in a child template, an /html folder is created in the child template’s folder structure, it automatically contains all overrides being created for that child template.

Practical Override Strategies for Maintainable Joomla Sites

To keep your Joomla site maintainable, don't put changes directly into core component or module files. These files will be overwritten and lost when the extension is updated.

Instead, use Joomla’s Template Manager, which automatically creates overrides for you. Choose a component or module you wish to change, and Joomla copies the files into the template's html folder. Now all those copies can be customized – with your changes preserved during upgrades.