Magento 2: How to make a custom theme computable with Magento 2.4.x

Here is an example of how you can create a custom theme in Magento 2:

  1. Create a directory for your theme under app/design/frontend/[Vendor]/[Theme]
  2. Create a theme.xml file in your theme directory with the following content:
 

[code]
<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>
</theme>
[/code]


  1. Create a composer.json file in your theme directory with the following content:

[code]
{
“name”: “vendor/theme”,
“description”: “My Custom Theme”,
“require”: {
“php”: “~7.1.3||~7.2.0||~7.3.0”,
“magento/theme-frontend-blank”: “100.2.*”,
“magento/framework”: “100.2.*”
},
“type”: “magento2-theme”,
“version”: “1.0.0”,
“license”: [
“OSL-3.0”,
“AFL-3.0”
],
“autoload”: {
“files”: [
“registration.php”
]
}
}
[/code]
 


  1. Create a registration.php file in your theme directory with the following content:
[code]
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
‘frontend/Vendor/theme’,
__DIR__
);
[/code]


  1. Run the following command from the Magento root directory to register your theme:

[code]
php bin/magento setup:upgrade
php bin/magento setup:deploy -f
[/code]
 
  1. Log in to the Magento Admin and navigate to Content > Design > Configuration
  2. Click the Edit button for the store view you want to apply your custom theme to
  3. In the Design Configuration page, select your custom theme in the Applied Theme dropdown
  4. Click the Save Configuration button

Your custom theme should now be active for the specified store view.

You can now start creating custom templates, layouts, and styles for your theme. For more information, you can refer to the Magento 2 documentation on creating a custom theme: https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/themes/theme-create.html

Leave a Reply

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