To Create New Theme in Magento 2 (Part 1) you need to follow:
- Step 1: Create a theme directory
- Step 2. Declare your theme
- Step 3: Add registration.php
- Step 4: Configure images
Hello everyone ! As you know, theme is one of the important part of Magento. Depend on your business, you need the theme which is suitable to your website. In this blog, I will show you how to create a simple theme in Magento 2.
Step 1: Create a theme directory
- Go to <your Magento install dir>/app/design/frontend.
- Create a new directory named according to your vendor name: /app/design/frontend/Magestore
- Under the vendor directory, create a directory named according to your theme: /app/design/frontend/Magestore/SimpleTheme
│ │ ├──…<theme>/
│ │ │ ├── …
│ │ │ ├── …
Step 2. Declare your theme
Create the theme.xml in app/design/frontend/Magestore/SimpleTheme
- Add or copy from an existing theme.xml to your theme directory app/design/frontend/Magestore/SimpleTheme
- Configure it using the following example:
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>Magestore Simple Theme</title> <!-- your theme's name -->
<parent>Magento/blank</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
<preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image -->
Step 3: Add registration.php
To register your theme in the system, in your theme directory add a registration.php file with the following content:
Step 4: Configure images
Product image sizes and other properties used on the storefront are configured in a view.xml configuration file. It is required for a theme, but is optional if exists in the parent theme. If you want to change the configuration to different the parent theme, please follow three steps:
- Create the etc directory in your theme folder (app/design/frontend/Magestore/SimpleTheme)
- Copy view.xml from the etc directory of an existing theme (for example, from the Blank theme) to your theme’s etc directory.
- Configure all storefront product image sizes in view.xml.
To Create New Theme in Magento 2, this post will describe the way easily, and when coming to the next topics you might also get the guides about the Create New Theme in Magento 2 part 2.
The 4 steps I mention above is the shortest process for you to Create New Theme in Magento 2. With this guide, you can manage the New Theme in Magento 2 easily. Every store has a New Theme in Magento 2 with many attributes.
Thank you for reading this post.