skip to Main Content

I am brand new to Magento, and am using Magento 2. I have a custom theme that has been working just fine. Suddenly, the files in my custom theme’s Magento_Theme/layout folder seem to not be loading. In my layout folder I have default_head_blocks.xml and default.xml. BOTH files suddenly stopped working.

Here is my default_head_blocks.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">
  <head>
    <css src="css/bootstrap.min.css" />​
    <css src="css/styles-m.css" />
    <css src="css/styles-l.css" media="screen and (min-width: 768px)"/>

    <script src="js/bootstrap.min.js"/>
    <script src="js/site.js"></script>
 </head>
</page>

And my 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">
  <body>
    <referenceContainer name="header.panel">
        <block class="MagentoFrameworkViewElementHtmlLinks" name="header.links">
            <arguments>
                <argument name="css_class" xsi:type="string">header links</argument>
            </arguments>
        </block>
    </referenceContainer>
    <referenceContainer name="footer">
        <block class="MagentoThemeBlockHtmlFooter" name="absolute_footer" template="html/absolute_footer.phtml" />
    </referenceContainer>
    <referenceBlock name="report.bugs" remove="true"/>
    <referenceBlock name="store.settings.currency" remove="true"/>
    <referenceBlock name="catalog.compare.sidebar" remove="true"/>
    <referenceBlock name="advanced-search-link" remove="true"/>
    <referenceBlock name="skip_to_content" remove="true"/>
    <referenceBlock name="store_switcher" remove="true"/>
    <referenceBlock name="navigation.sections" remove="true"/>
    <referenceBlock name="top.search" remove="true"/>
    <referenceBlock name="footer_links" remove="true"/>
    <move element="copyright" destination="before.body.end"/>
    <move element="logo" destination="navigation.sections"/>
    <move element="form.subscribe" destination="footer"/>
    <move element="catalog.topnav" destination="header.container"/>
    <move element="top.links" destination="footer"/>
 </body>
</page>

As I stated the files were working perfectly fine at one point.

The files in my Magento_Theme/templates/html folder load just fine. Seems to only be the files in my layout folder.

Any ideas why this would be happening or how to fix it?

4

Answers


  1. From my experience, instances like this would require you to do the following.

    Clean Cache:

    php bin/magento cache:clean
    

    Flush Cache:

    php bin/magento cache:flush
    

    (optional) if clearing cache doesn’t seem to show any changes, you might need to do a static deploy.

    Static Deploy: Note: this will take a bit of time depending on your system.

    php ./bin/magento setup:static-content:deploy --theme <your theme example myTheme/Default>
    

    After these processes you can try and reload the page again.

    Login or Signup to reply.
  2. You have added <script> in a wrong way inside inside the file default_head_blocks.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">
      <head>
       <css src="css/bootstrap.min.css" />​
       <css src="css/styles-m.css" />
       <css src="css/styles-l.css" media="screen and (min-width: 768px)"/>
       <script src="js/bootstrap.min.js"/>
       <script src="js/site.js"/>
      </head>
     </page>
    

    Static Deploy:

     php bin/magento setup:static-content:deploy
    

    Flush Cache:

     php bin/magento cache:flush
    
    Login or Signup to reply.
  3. Just go to website database, open theme table and chagne type = 0 for your current theme. That’s it 🙂

    Login or Signup to reply.
  4. There’s an issue with default_head_blocks.xml if the theme type is set to virtual. Check the type field in the theme table. If it’s set to 1, try setting it to 0. Then clear the cache and reload the page. See if that does the trick.

    See also: https://github.com/magento/magento2/issues/4330

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search