I created a custom child theme for luma and it works fine. But when I extend the layout for Magento_Theme I start getting all kinds of javascript errors which are random, sometimes they don't appear at all.

Below is my folder structure

enter image description here

The problem appears when I add the Magento_Theme folder.

Below is the content of default.xml

<?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">
        <referenceContainer name="footer-container">
            <block class="Magento\Theme\Block\Html\Footer" name="footer" template="html/footer.phtml">
                <block class="Gs\Core\Block\Mailchimp" name="mailchimp" template="Gs_Core::mailchimp/form.phtml" />

and default_head_blocks.xml

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <!--Bootstrap css-->
        <css src="css/bootstrap.min.css" />

Below is a sample of the errors:

enter image description here

I have tried recompiling, clearing cache, forcing a static content deploy manually deleting the static folder and the generated folder with no luck.

2 Answers 2


I found the problem. The mailchimp.phtml had js code that was causing require.js to break.


From above code not sure what you did wrong but you can take the reference to create the custom theme from here

After copy from reference code,

1) Paste into your app/design/frontend folder

2) Run this command php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy -f from root directory of magento

3) Go to the admin side Content -> Design -> Theme check your newly installed theme there or not?

4) If you see your theme listed in theme tab then Go to Content -> Design -> Configuration -> Click Edit on first record -> click on Applied Theme drop-down choose your new theme

5) save the configuration and go to frontend just refresh a page

6) if you see broken UI run this command php bin/magento cache:clean && php bin/magento cache:flush

7) if you still see broken UI follow Step 2

8) paste you required CSS/js in respected folders in the new theme

that's it let me know if you have any query

  • The problem was a script in one of the mailchimp templates. Commented Oct 6, 2018 at 8:18

Your Answer

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

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