Magento – error during deploying custom theme in magento 2

magento2theme

i am working on theme in magento 2,but i am getting error in terminal(CMD),the error message is "unable to load theme by specified key:My/Helloworld" when i run php bin\magento setup:static-content:deploy, my required file are
app\design\frontend\My\Helloworld\composer.json

{
    "name": "magento/theme-frontend-My",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.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"
        ]
    }
}

app\design\frontend\My\Helloworld\registration.php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/My/Helloworld',
    __DIR__
);

Best Answer

A common oversight which could throw this error is forgetting to run:

bin/magento setup:upgrade

This allows Magento to register your theme in the 'theme' table of the Magento database. You can check if your theme is registered via the mysql command line:

mysql> use <your magento database>;
mysql> SELECT * FROM theme;

If your theme is registered also make sure that the 'type' column value for your theme record is 0. Values of 1 can also lead to this error.

Related Topic