Create Magento 2 Custom theme
Create Magento 2 Custom theme
Create Magento 2 Custom theme
Create Magento 2 Custom theme firstly we need to set mode as developer you know magento have three type mode:
Default Mode
Developer Mode
Production Mode
Run blow cammand set mode as developer
php bin/magento deploy:mode:set developer
Step 1 – Create theme.xml
Create theme directory app/design/frontend/techdiv/techdivtheme
app/design/frontend/techdiv/techdivtheme/etc/theme.xml
<theme xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Config/etc/theme.xsd”>
<title>Techdivtheme</title>
<parent>Magento/Luma</parent>
<media>
<preview_image>media/td-theme-image.jpg</preview_image>
</media>
</theme>
Step 2 – composer.json
app/design/frontend/techdiv/techdivtheme/composer.json
{
“name”: “techdiv/techdivtheme”,
“description”: “N/A”,
“require”: {
“php”: “~5.6.5|~7.0.0|7.0.2|7.0.4|~7.0.6|~7.1.3|~7.2.0”,
“magento/theme-frontend-blank”: “100.0.*”,
“magento/framework”: “100.0.*”
},
“type”: “magento2-theme”,
“version”: “100.0.1”,
“license”: [
“OSL-3.0”,
“AFL-3.0”
],
“autoload”: {
“files”: [
“registration.php”
]
}
}
Step 3- registration.php
app/design/frontend/techdiv/techdivtheme/registration.php
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
‘frontend/techdiv/techdivtheme’,
__DIR__
);
Step 4- app/design/frontend/techdiv/techdivtheme/media
upload preview_image which path define in theme.xml
run below cammand:
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush
Add custom css custom theme in magento 2
Step 1 –
Create folder Magento_Theme
And create file default_head_blocks in layout/default_head_blocks
app/design/frontend/techdiv/techdivtheme/Magento_Theme/layout/default_head_blocks
<?xml version=”1.0″?>
<page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”>
<head>
<css src=”css/custom-m.css”/>
<css src=”css/custom-l.css” media=”screen and (min-width: 768px)”/>
</head>
</page>
Step 2-
Create web folder
app/design/frontend/techdiv/techdivtheme/web
Add custom css : css/custom-m.css , css/custom-l.css
Admin shows the created child theme.
Login into admin panel
Go to Content > Themes
Edit Theme and Save !!
Run Cammand : bin/magento setup:static-content:deploy