Creating a new theme in Magento 2.4.7 that inherits from the Luma theme involves several steps. Here’s a detailed guide on how to achieve this:
app/design/frontend/<Vendor>/<theme_name>
Replace <Vendor>
with your vendor name and <theme_name>
with your theme name.
theme.xml
at app/design/frontend/<Vendor>/<theme_name>/theme.xml
.theme.xml
:
XML file
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>Your Theme Title</title> <!-- Theme title -->
<parent>Magento/luma</parent> <!-- Inherit from Luma theme -->
<media>
<preview_image>media/preview.jpg</preview_image> <!-- Theme preview image -->
</media>
</theme>
registration.php
at app/design/frontend/<Vendor>/<theme_name>/registration.php
.registration.php
:PHP file
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/<Vendor>/<theme_name>',
__DIR__
);
composer.json
at app/design/frontend/<Vendor>/<theme_name>/composer.json
.composer.json
:Json File
{
"name": "vendor/theme-name",
"description": "Magento 2 custom theme",
"require": {
"php": "~7.4.0||~8.1.0",
"magento/framework": "*",
"magento/theme-frontend-luma": "*"
},
"type": "magento2-theme",
"version": "1.0.0",
"license": "OSL-3.0",
"autoload": {
"files": [
"registration.php"
]
}
}
app/design/frontend/<Vendor>/<theme_name>/web
.If you want to customize specific layouts or templates, you can create directories like layout
, templates
, and Magento_Theme
within your theme directory and add your customizations there.
Run into the command line
bin/magento setup:upgrade
bin/magento setup:static-content:deploy -f
bin/magento cache:clean
Content
> Design
> Configuration
.Edit
.Applied Theme
dropdown, select your new theme, and save the configuration.To override the header, copy the Luma theme’s header files to your custom theme and make your modifications.
header.phtml
file from the Luma theme:cp vendor/magento/theme-frontend-luma/Magento_Theme/templates/html/header.phtml app/design/frontend/acesoftech/acesoftech_academy/Magento_Theme/templates/html/header.phtml
header.phtml
file in your custom theme as needed.cp vendor/magento/theme-frontend-luma/Magento_Theme/layout/default.xml app/design/frontend/acesoftech/acesoftech_academy/Magento_Theme/layout/default.xml
default.xml
file in your custom theme as needed.After creating your custom theme and making the necessary modifications, deploy the static content:
bin/magento setup:upgrade
bin/magento setup:static-content:deploy -f
bin/magento cache:clean
acesoftech_academy
) as the default theme for the store.By following these steps, you will create a custom theme that inherits from the Luma theme and allows you to override and customize various aspects of the Luma theme.
Get Magento Training in India from a professional trainer. who has industry experience.