How to Create a Hyvä Child Theme

Folder structure, registration.php, theme.xml and the Tailwind setup for a child theme that survives updates.

How to Create a Hyvä Child Theme – illustration

Editing the default theme directly means losing your changes at the next update. A child theme inherits everything from Hyva/default and holds only your customisations, so updates remain routine and your work stays clearly separated from the vendor's.

This guide builds a child theme called Acme/storefront from an empty folder to an activated theme, then covers how to override templates and layouts safely.

How theme inheritance works

Magento themes form a chain. When a page needs a template, layout file or static asset, Magento looks first in the active theme, then in its parent, and so on up the chain. A child theme therefore only needs to contain the files it changes.

For Hyvä, the chain is usually Acme/storefront → Hyva/default → Hyva/reset. The reset theme removes Luma's layout instructions so they do not leak into your storefront.

1. Create the folder

Choose a vendor name and a theme name, using only letters and numbers. Then create the directory:

app/design/frontend/Acme/storefront/

2. Add registration.php

This file tells Magento the theme exists:

<?php
use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
    ComponentRegistrar::THEME,
    'frontend/Acme/storefront',
    __DIR__
);

3. Add theme.xml

The parent element is what makes this a Hyvä child theme:

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Acme Storefront</title>
    <parent>Hyva/default</parent>
    <media>
        <preview_image>media/preview.png</preview_image>
    </media>
</theme>

The preview image is optional and appears only in the admin theme list.

If the theme will be installed through Composer or shared between projects, add a composer.json that declares the package name, type magento2-theme and a dependency on hyva-themes/magento2-default-theme. For a theme that lives only in one project's app/design folder, this step can wait.

5. Copy the Tailwind workspace

Copy the web/tailwind folder from the parent theme, usually found at vendor/hyva-themes/magento2-default-theme/web/tailwind, into your theme. Leave out node_modules.

Then check that the source paths in your Tailwind entry file include both your theme and the parent theme. This matters because many of your pages will still use templates inherited from the parent, and their classes must be compiled too.

cd app/design/frontend/Acme/storefront/web/tailwind
npm ci
npm run build

6. Register and activate

bin/magento setup:upgrade
bin/magento hyva:config:generate
bin/magento cache:flush

Then select Acme Storefront under Content > Design > Configuration, save and flush the cache again. Your store now runs on the child theme, which at this point looks identical to the default.

The finished structure

app/design/frontend/Acme/storefront/
├── registration.php
├── theme.xml
├── composer.json
├── media/preview.png
├── web/
│   ├── css/styles.css        (generated)
│   └── tailwind/
│       ├── package.json
│       └── tailwind-source.css
├── Magento_Theme/
│   ├── layout/default.xml
│   └── templates/html/header.phtml
└── Magento_Catalog/
    └── templates/product/list.phtml

Overriding templates safely

To change a template, copy only that file into the matching path in your theme. For example, the product list lives at Magento_Catalog/templates/product/list.phtml. Magento will use your copy and fall back to the parent for everything else.

  • Override as few files as possible; each copy must be reviewed when the parent changes.
  • Note the parent version in a comment at the top of each overridden file.
  • After updating Hyvä, compare your overrides with the new parent templates and merge relevant changes.

Using layout XML instead of copies

Many changes do not need a template copy at all. Layout XML can move, remove or reorder blocks, change arguments and add new blocks. For example, removing the compare link from product pages takes one line in a layout file, with nothing copied from the parent.

<referenceBlock name="product.info.addto.compare" remove="true"/>

Prefer layout changes wherever they achieve the goal. They are shorter, clearer and far less likely to break when Hyvä is updated.

Version control and deployment

Keep the theme in version control, but exclude node_modules. Decide whether the compiled styles.css is committed or built in CI, and document that choice for the team. Either works; what matters is that every deployment ships a freshly built stylesheet.

Adding custom fonts and images

Place font files in your theme's web/fonts folder and declare them with @font-face in the Tailwind entry file, then point the --font-sans token at the new family. Self-hosting fonts avoids an extra connection to a third-party service and gives you full control over loading.

Images such as logos and icons belong in web/images. Reference them in templates through Magento's asset repository, so URLs include the correct static path and version for cache busting.

Adding your own JavaScript

Most behaviour in a Hyvä theme lives in Alpine components inside templates. For code that must run on every page, such as an analytics helper, add a small template containing a script block and include it through layout XML in a container near the end of the page body. Keep such scripts short; every global script affects every page.

Translations

Text in templates should pass through Magento's translation function, for example $escaper->escapeHtml(__('Add to Cart')). Theme-specific wording can then be changed in an i18n/en_GB.csv file inside your theme, without editing templates. The same mechanism supports additional store languages.

Multi-store and multi-brand setups

For several brands on one Magento installation, a common pattern is a shared base theme that inherits from Hyva/default, with a slim child theme per brand. The base theme holds shared templates and components; each brand theme mainly changes design tokens, logos and a few templates.

Each theme in the chain compiles its own stylesheet, so make sure every brand theme's Tailwind sources include the base theme's templates as well as its own.

A routine for updates

Keep a short list of the files your theme overrides, with the parent version each was copied from. When Hyvä releases an update, compare each override with the new parent file and merge relevant changes. With few overrides, this takes minutes; with many, it can take days, which is the strongest argument for keeping them few.

Conclusion

A Hyvä child theme needs three essentials: registration.php, a theme.xml naming Hyva/default as parent, and its own copy of the Tailwind workspace. Keep overrides few and deliberate, prefer layout XML to template copies, and review your overrides after each update. That discipline keeps upgrades quick for the life of the store.

Frequently Asked Questions

You can, but your changes will be overwritten when Composer updates the package. A child theme keeps them safe.

Yes. Each Hyvä theme compiles its own stylesheet, so the child theme needs a copy of the web/tailwind folder.

Yes. Magento supports multiple levels of inheritance, which is useful for multi-brand stores sharing a base design.

Usually the stylesheet has not been built or deployed. Run npm run build, deploy static content and flush the cache.

Sources and Further Reading

Hyvä Editorial Team
Hyvä Editorial Team

We write practical guides on the Hyvä theme for Magento 2, checked against the official documentation and public repositories. How we research