Custom theme selection
-
04-10-2020 - |
Question
I am new to Magento front end development while creating my custom theme,
I have created app\design\frontend\custom\themename and inside that created my theme.xml file.
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>themename</title> <!-- your theme's name -->
<parent>Magento/blank</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
<media>
<preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image -->
</media>
</theme>`
But in Stores->Configuration->Design->Design Theme not showing my theme name in dropdown
Solution
You need to create media folder and inside that folder add your preview.jpg
file.
Create registration.php
file inside theme,
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/custom/themename',
__DIR__
);
Run command,
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
Check your theme inside
Content -> Design -> Configuration
Clear cache and var folder content.
Thanks.
OTHER TIPS
You need to create registration.php to register your theme.
Registration.php file code :
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/Vendorname/themename',
__DIR__
);
After that clear the cache by running cache:clean command and check it will show in design configuration setting dropdown
Also from admin click on Content->Design->Configuration here you can see your custom theme
For more details refer this link - http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/theme-create.html