1

I am trying to build a custom theme for magneto2 and noticed the theme files for luma and blank are located under the vendor folder and app/design/Magento is empty. I have a couple of questions regarding this. I went by the documentation on magento website and created a folder under app/design which followed their structure. It doesn't seem like my custom theme is inheriting the parent. Do I need to move the theme I want from the vendor folder up to app/design/magento/blank inorder for it to inherit? Has anyone else have this issue. I noticed there is a lot of questions on here regarding this but none of them have answers or the ones that do have answers suggest not getting the zip and using the file from git. Can anyone shed some light on this?

2

Follow these steps for create a theme now you need to create files one by one.

theme.xml ( app/design/frontend/mycompany/basic/theme.xml )

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
   <title>Basic</title> <!-- your theme's name -->
   <parent>Magento/blank</parent> <!-- the parent theme -->
   <media>
        <preview_image>media/preview.jpg</preview_image> <!-- theme's preview image -->
   </media>
</theme>

registration.php ( app/design/frontend/mycompany/basic/registration.php )

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/mycompany/basic',
    __DIR__
);

default.xml ( app/design/frontend/mycompany/basic/Magento_Theme/layout/default.xml )

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="logo">
           <arguments>
              <argument name="logo_file" xsi:type="string">images/my_logo.png</argument>
              <argument name="logo_img_width" xsi:type="number">200</argument>
              <argument name="logo_img_height" xsi:type="number">200</argument>
           </arguments>
        </referenceBlock>
    </body>
</page>

At this point, our theme is ready. Clear your cache and we will now select our new theme from admin.

Now, login to admin and move to following path:

Content -> Design -> Themes

You should see your theme listed.

Now go to:

Stores -> Configuration -> Design

Choose Main Website in front of Store View at top left. Now click

Desgin -> Design Theme

Uncheck Use Default checkbox and pick your theme. Click Save Config, clear your cache and your new theme is ready. Check your home page.

For more detail see here.

1

The file required to set a parent theme is app/design/frontend/**VENDOR**/**THEME**/theme.xml. This is all you need to do, if this doesn't work then try clearing your cache, and clearing var/pre_processed and pub/static (and running php bin/magento setup:static-content:deploy if you're in production mode). If this doesn't work then check your theme for errors.

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
   <title>Basic</title> <!-- your theme's name -->
   <parent>Magento/blank</parent> <!-- the parent theme -->
   <media>
        <preview_image>media/preview.jpg</preview_image> <!-- theme's preview image -->
   </media>
</theme>

This line is the line you define a parent:

<parent>Magento/blank</parent>

For example if you wanted to inherit from Luma (Magento advise against this as it's their demo theme) you would use:

<parent>Magento/luma</parent>

If you have already done that then I suspect it'll be related to caches, or you still have Magento set to production mode so you need to run the static content deploy command I noted at the top of my comment.

I wouldn't advise moving any directories from the vendor folder.

1

I was able to get this to work using the above instructions. One thing I wanted to mention is your theme will not inherit and compile unless you have a file in the web folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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