Creating an own theme for Magento

Creating an own theme for Magento

July 13, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Creating an own theme for Magento

Creating Your Own Theme for Magento: A Comprehensive Guide

Creating your own theme for Magento can be a rewarding experience, allowing you to customize the look and feel of your e-commerce platform to match your brand perfectly. While there are many outdated tutorials available online, this guide will provide you with an up-to-date, step-by-step walkthrough to help you build a new theme from scratch.

Understanding the Magento Theme Structure

Before diving into the creation process, let’s briefly discuss the key components of a Magento theme:

  1. Theme Folder: The main folder for your theme.
  2. Skin Folder: Contains CSS and JavaScript files.
  3. Template Folder: Holds the HTML templates used to render product listings, categories, etc.

Setting Up Your Theme: The Basics

First, you need to create a new folder in the app/design/frontend directory for your theme. For example:

mkdir app/design/frontend/vendor/theme

Replace ‘vendor’ with your Magento Connect username or company name and ‘theme’ with the desired theme name.

Next, create the necessary sub-folders inside this new theme folder:

mkdir -p app/design/frontend/vendor/theme/Magento_Catalog/templates/app/design/frontend/vendor/theme/Magento_Checkout/templates

Defining Your Theme in theme.xml

In your main theme folder, create a file named theme.xml. This file defines the theme’s metadata and inheritance.

<?xml version="1.0"?>
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config etc/theme.xsd">
    <title>My Custom Theme</title>
    <parent>Magento/blank</parent>
    <media>
        <preview_image>media/preview.png</preview_image>
        <logo>media/logo.svg</logo>
    </media>
</theme>

In this example, Magento/blank is the parent theme. You can also use Magento/luma for a more feature-rich base.

Customizing Your Theme with Templates and CSS

Now let’s start customizing the appearance of your theme:

1. Creating a New Template

Navigate to the app/design/frontend/vendor/theme/Magento_Catalog/templates folder you created earlier.

cp catalog_product_view_type_empty.phtml product-list.phtml

This copies an existing template and renames it so we can modify it later. Open the new product-list.phtml file in your preferred text editor or IDE.

2. Editing the Template

Modify the contents of the product-list.phtml file to add your custom HTML structure for displaying products:

<?php foreach ($block->getProductList() as $_product): ?>
    <div class="product-item">
        <h3><a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>"><?php /* @escapeNotVerified */ echo $_product->getName() ?></a></h3>
        <p class="price">$<?php /* @escapeNotVerified */ echo $_product->getPrice() ?></p>
    </div>
<?php endforeach; ?>

3. Adding CSS Styling

Create a new file named styles.less in the app/design/frontend/vendor/theme/web/css/source folder:

@import 'lib/scss/mixins';
.product-item {
    border: 1px solid #ddd;
    padding: 20px;
    margin-bottom: 30px;
}

This LESS file will be compiled into a CSS file by Magento’s built-in Less compiler.

Enabling Your New Theme

To enable your new theme, log in to the Magento admin panel and navigate to Content > Design > Configuration. Click on the “Edit” button for your current configuration scope. In the “Default Theme” dropdown, select your new theme name and save changes.

Conclusion

Creating a custom theme for Magento requires understanding the platform’s folder structure, modifying templates using PHP, and adding CSS styling with LESS files. By following this comprehensive guide, you should now be able to build and enable your own themes with ease.

Remember, Magento’s documentation is an invaluable resource. For more advanced topics like UI components or working with JavaScript, refer to the official Magento developer documentation.

Happy theming! Let us know in the comments if you have any questions or success stories to share about creating your own Magento themes.

Checkout Catalog Themes Configuration

Our network