Skip to main content

2.5 - Styles, copies and child templates

This is the point everyone trips over, including after years of Joomla. It comes down to one sentence:

The template holds files. The style holds settings.

Everything else follows from that. If you remember one line from this page, make it that one.

One template, several styles

You install Corpus once. It is a folder of files: the layouts, the stylesheet, the images, the content blocks.

You then create as many styles as you like: Home, Landing page, Press room. A style duplicates no file at all - it is a row in the database saying "for these pages, Corpus with this hue, this logo, these positions".

Creating thirty styles makes neither the site nor its updates any heavier.

That is what you want nine times out of ten: System → Site Template Styles → select a style → Duplicate.

What a style holds, exactly

  Where it is stored
Hue, message colours the style
Logo, site name, tagline the style
Layout, positions, widths the style
Shape variant, typography the style
Layouts, stylesheet, shipped images the template

A style is therefore a set of settings, and nothing else. It cannot change the markup of a page: for that you must touch files, and that is where a child template comes in.

When you duplicate, Joomla copies the settings into the new style. At that moment the two are identical; afterwards they live their own lives.

There is no inheritance between styles. Changing the original will not change the copy. If you change the site hue after creating five styles, you will change it five times. That is the price of independence, and it is worth thinking about before duplicating: set what is common first, duplicate after.

So where does the logo come from?

The Logo field does not hold an image: it holds a path to a file in your media library, something like images/logo.png.

Duplicating a style therefore copies that path. Both styles point at the same file, present once on disk. Changing the logo in one style only changes that style's path; the original image does not move, and the other styles go on using it.

The same is true of every media field in the Theme Customizer: they are addresses, not copies.

When a child template becomes necessary

A child template duplicates a folder of files. It serves one purpose, but an important one:

Override a Corpus file without the next update wiping it out.

If you edit templates/corpus/html/com_content/article/default.php, your work will vanish the next time a version of Corpus is installed. A child keeps it safe: Joomla uses the child's file if it exists, the parent's otherwise.

A child does not inherit settings. It has its own styles. When you create one, Joomla offers to duplicate the existing styles - the Additional template styles box - but those are photocopies too.

The question to ask, in two steps

1. Do I need to change a value, or a file?

A colour, a logo, a module position, a width: a value → a style is enough.

An article's markup, a component override, a CSS rule the settings do not allow: a file → child template.

2. Am I ever going to update Corpus?

If yes - and the answer is yes - any file change made inside templates/corpus/ is living on borrowed time. Make it in a child.

Worth noting: Corpus's Custom CSS field, under Advanced settings, is not affected. It lives in the style, in the database: no update erases it. For CSS tweaks it is safer and simpler than a child.

Three traps worth knowing

The default style. Only one carries the star. It applies everywhere no other style is assigned - and it is also the one Corpus reads for settings that apply to the whole site, such as cookie consent.

Menu assignment. A style applies to pages by being assigned to menu items, in its Menu Assignment tab. A page reached some other way - a direct link, a search - gets the default style. Do not rely on a style to carry a rule that must hold everywhere.

The settings stylesheet. Corpus generates one CSS file per style, named after its id. That is normal, and it is what lets two styles have two hues without colliding. There is nothing for you to do there, but if you copy a site by hand, do not forget that folder.

Up to date for Corpus 2.1.43.