1

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__
);
5

3 Answers 3

5

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.

0
1

have you declare theme name from di.xml like below. Below code is the example for creating backend.

<type name="Magento\Theme\Model\View\Design">
    <arguments>
        <argument name="themes" xsi:type="array">
            <item name="frontend" xsi:type="string">Magento/luma</item>
            <item name="adminhtml" xsi:type="string">Learning/backend</item>
        </argument>
    </arguments>
</type>

and run the below commands in CLI

  1. php bin/magento cache:clean
  2. php bin/magento setup:upgrade
  3. php bin/magento setup:static-content:deploy

if still not working go to admin panel clear the cache and clear the flush and re run above commands it will work.

2
  • Let me get this clear: do I need to add this to the di.xml of my module? Still doesn't work for me ... Mar 24, 2016 at 13:06
  • @GielBerkers, Yes ad the di.xml file. Apr 1, 2016 at 11:13
1

I have the same issue, this may be due to cache files

Remove following directories pub/static, var/cache, var/composer_home, var/generation, var/page_cache,var/view_preprocessed

Then run the following command line from terminal/shell: php bin/magento setup:static-content:deploy

1
  • After following your instructions I got: There are no commands defined in the "setup:static-content" namespace
    – m.spyratos
    Jun 22, 2017 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.