Skip to content
kb

Custom Hyvä Theme Development: A Step-by-Step Guide

· By Anna Hyva · 8 min read

Hyvä Theme is a fresh and light option for Magento 2 shops that delivers great performance and makes things easier for developers. If you want to create a custom Hyvä theme for your Magento store, this guide will help you step by step in a way that’s easy to understand.

Step 1: Get Your Development Setup Ready

First, ensure you have all the tools you need, like Magento 2, Composer, Node.js, and the Hyvä Theme package installed. If you’re looking to buy the Hyvä Theme, you can grab it from our official website and set it up on your Magento store.

Step 2: For Licensees

Visit this link Hyva-Theme-License to get a valid license and Private Packagist key.

Step 3: Install Hyvä Theme

After you buy the Hyvä theme development service, it’s time to install and enable it in Magento. Go to the Magento admin panel and set it as your active theme. Don’t forget to run all the required setup commands so the theme works right.

#replace yourLicenseAuthentificationKey AND yourProjectName with your own details.
composer config --auth http-basic.hyva-themes.repo.packagist.com token yourLicenseAuthentificationKey
# replace yourProjectName with your project name
composer config repositories.private-packagist composer https://hyva-themes.repo.packagist.com/yourProjectName/

Then, install the theme package and its dependencies:

composer require hyva-themes/magento2-default-theme

Next, run the Magento installer:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Important Note:

In developer mode, you should now see the theme in action on the frontend. A cache flush might be required. Run one of the following commands:

php bin/magento cache:flush

In production mode, run on of the following command:

php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Navigate to the Content > Design > Configuration admin section and activate the hyva/default theme.

Step 4: Create a Custom Hyvä Theme

If you want to personalize Hyvä without messing with the core files, you should make a child theme. This way, you can tweak things while keeping the original Hyvä theme safe. Just register and set up the child theme in your Magento environment.

1. Create Theme Directory

Go to:

app/design/frontend/YourVendorName/YourThemeName/

Example:

app/design/frontend/HyvaGo/hyva-child/

Create this folder structure:

app/
└── design/
    └── frontend/
        └── HyvaGo/
            └── hyva-child/
                ├── registration.php
                ├── theme.xml
                ├── composer.json
                ├── media/
                │   └── preview.png
                └── web/

(Create empty files for now — content is next.)

2. Files Content:

registration.php

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

ComponentRegistrar::register(
    ComponentRegistrar::THEME,
    'frontend/HyvaGo/hyva-child',
    __DIR__
);

theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>HyvaGo Hyva Child</title> <!-- Your theme name -->
    <parent>Hyva/default</parent> <!-- Important: set Hyva/default as parent -->
    <media>
        <preview_image>media/preview.png</preview_image> <!-- Make sure you have preview.png -->
    </media>
</theme>

composer.json

{
    "name": "hyvago/hyva-child",
    "description": "HyvaGo Hyva Child Theme",
    "require": {
        "magento/framework": "*"
    },
    "type": "magento2-theme",
    "version": "1.0.0",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ]
}

preview.png

Create a dummy preview.png inside media/. (It can be any small image.)

3. Copy the web/ Directory

Copy this:

vendor/hyva-themes/magento2-default-theme/web/

Paste into:

app/design/frontend/HyvaGo/hyva-child/web/

It contains Tailwind config, CSS, JS, etc.

4. Update Tailwind Config

Open:

app/design/frontend/HyvaGo/hyva-child/web/tailwind/tailwind.config.js

Uncomment these parent theme content paths:

content: [
    '../../**/*.phtml',
    '../../*/layout/*.xml',
    '../../*/page_layout/override/base/*.xml',
    '../../../../../../../vendor/hyva-themes/magento2-default-theme/**/*.phtml',
    '../../../../../../../vendor/hyva-themes/magento2-default-theme/*/layout/*.xml',
    '../../../../../../../vendor/hyva-themes/magento2-default-theme/*/page_layout/override/base/*.xml',
]

This tells Tailwind to scan your child and parent theme files for CSS classes.

5. Enable the Theme

From Admin Panel:

Content > Design > Configuration > Edit Store View > Select your theme: HyvaGo Hyva Child.

Or using CLI:

bin/magento theme:enable frontend/HyvaGo/hyva-child
php bin/magento cache:flush

6. Build Tailwind styles.css

Now generate the final Tailwind CSS file!

npx tailwindcss -c app/design/frontend/HyvaGo/hyva-child/web/tailwind/tailwind.config.js -i app/design/frontend/HyvaGo/hyva-child/web/css/tailwind.css -o pub/static/frontend/HyvaGo/hyva-child/en_US/css/styles.css

This will create your styles.css automatically.

Step 5: Customize Layout and Templates

Hyvä uses Tailwind CSS and Alpine.js for customizing the front. You can change layout files and templates to fit your brand’s style. Use Tailwind CSS for styling and add interactive elements with Alpine.js.

For the Header:

  1. Copy the vendor theme header template from vendor/hyva-themes/magento2-default-theme/Magento_Theme/templates/page/html/header.phtml to your child theme directory at app/design/frontend/HyvaGo/hyva-child/Magento_Theme/templates/page/html/header.phtml
mkdir -p app/design/frontend/HyvaGo/hyva-child/Magento_Theme/templates/page/html/
cp vendor/hyva-themes/magento2-default-theme/Magento_Theme/templates/page/html/header.phtml app/design/frontend/HyvaGo/hyva-child/Magento_Theme/templates/page/html/

2. Once copied, you can modify the header.phtml file in your child theme to implement your custom design with Tailwind CSS classes, like this:

<header class="bg-blue-500 text-white py-4">
    <div class="container mx-auto flex justify-between items-center">
        <!-- Logo Section -->
        <div class="flex items-center">
            <a href="<?= $block->getUrl() ?>" class="text-2xl font-bold">
                <img src="<?= $block->getViewFileUrl('images/logo.png') ?>" alt="Your Brand" class="h-8">
            </a>
        </div>

        <!-- Navigation Links -->
        <nav class="hidden md:flex space-x-6">
            <a href="<?= $block->getUrl('home') ?>" class="text-white hover:text-gray-200">Home</a>
            <a href="<?= $block->getUrl('shop') ?>" class="text-white hover:text-gray-200">Shop</a>
            <a href="<?= $block->getUrl('about') ?>" class="text-white hover:text-gray-200">About</a>
            <a href="<?= $block->getUrl('contact') ?>" class="text-white hover:text-gray-200">Contact</a>
        </nav>
    </div>
</header>

For the Footer:

  1. Create or edit footer.phtml in the same directory.
  2. Add custom footer code:
<footer class="bg-gray-800 text-white py-6">
    <div class="container mx-auto text-center">
        <p>© <?= date('Y') ?> Your Brand. All rights reserved.</p>
    </div>
</footer>

Customize Tailwind CSS:

  1. Locate or create tailwind.config.js in your theme’s root folder.
  2. Add your brand colors and other customizations:
module.exports = {
  theme: {
    extend: {
      colors: {
        primary: '#FF5733',  // Your primary color
        secondary: '#C70039', // Your secondary color
      },
    },
  },
}

3. Use these colors in your templates:

<div class="bg-primary text-white p-4">
    <h1 class="text-2xl">Welcome to Our Store!</h1>
</div>

Add Interactivity with Alpine.js:

  1. Make sure Alpine.js is included (it should be in Hyvä by default).
  2. Add interactive elements like a mobile menu:
<div x-data="{ open: false }" class="md:hidden">
    <button @click="open = !open" class="text-white">
        <span class="text-2xl">☰</span> <!-- Hamburger icon -->
    </button>
    <div x-show="open" class="bg-gray-800 text-white p-4 mt-2">
        <nav>
            <a href="<?= $block->getUrl('home') ?>" class="block py-2">Home</a>
            <a href="<?= $block->getUrl('shop') ?>" class="block py-2">Shop</a>
            <a href="<?= $block->getUrl('about') ?>" class="block py-2">About</a>
            <a href="<?= $block->getUrl('contact') ?>" class="block py-2">Contact</a>
        </nav>
    </div>
</div>

Override Layout XML (Optional):

If you need to change how elements are arranged:

  1. Create a layout file at app/design/frontend/HyvaGo/hyva-child/layout/default.xml.
  2. Add your customizations:
<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Model/Layout.xsd">
    <referenceContainer name="header.container">
        <block class="Magento\Framework\View\Element\Template" name="custom_header" template="Hyva_Go::page/custom_header.phtml"/>
    </referenceContainer>
</layout>

Step 6: Test and Go Live

Before your theme goes live, make sure to test it on different devices to check responsiveness and performance. Run some performance tests and fine-tune the front end for a speedy user experience. Once everything looks good, you can launch the theme on your live Magento store.

Level Up Your Magento 2 Store with Custom Hyvä Theme Development Service!

Creating a custom Hyvä theme can really improve your Magento store’s speed and overall experience. By following this guide, you can easily build and tweak a Hyvä-based theme that fits your business perfectly.

Looking for expert Hyva theme customization services? Don’t hesitate to reach out to Hyvago. We specialize in Hyva theme development and are here to support all your customization needs!

Leave a Reply

Your email address will not be published. Required fields are marked *