Magento – Why is the default.xml not working

magento-2.1xml

I have in my CustomTheme a default.xml file. I tried to get the xml to work and used some of the samples I found here on StackExchange. Non of them are working for me?
So apparently I have done something wrong or something else is interfering the xml file to be applied.

My default.xml resides in:

app/design/frontend///Magento_Theme/layout/default.xml

I cleared all cache, static files, the files in the /var and run setup:static-content:deploy

But nothing appears!

I tried several things like removing the footer links, and moving the shopping card like in this post:Magento 2 Block/Element order This is my latest trial default.xml the block is prepared in the cms_block.
Using Magento 2.1.2

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="footer">
            <block class="Magento\Cms\Block\Block" name="footer_social_links_block">
            <arguments>
                <argument name="block_id" xsi:type="string" translate="true">dth_footer_social_links</argument>
            </arguments>
            </block>
        </referenceBlock>        
 </body>
</page>

Best Answer

There's no issue in your layout file. Also, the layout file itself cannot be overridden by some extension. Only a separate parts (blocks, containers) can be overridden. Actually, there are many reasons why your changes are not being applied.

  • Your theme is not active at the moment. You have checked it. If changes in other layout files have effect, let's move forward.
  • The theme type is set as virtual. Known bug https://github.com/magento/magento2/issues/2996. But in that case not only default.xml but changes in all other layout files will have no effect.
  • The layout file is broken. It's not the case here
  • The path to the layout file is incorrect. It's always a good idea to double/triple check it.
  • The name of the layout file is incorrect. Believe or not, but cases like "defauit.xml" or similar can cost you few hours.
  • Your XML file has incorrect line endings and/or encoding. Sometimes it happens, you need to set UTF-8 encoding and Unix line endings for the layout file to be sure.

What would I recommend:

  • Make a parse error situation in the problematic file. Go to default.xml and remove some closing tag. Clear cache and reload a page. Then go to var/log/system.xml. If the file is handled by the system you will get "Theme layout update file .../default.xml is not valid" error there.
  • Make some change in the different default.xml file, for example app/design/frontend///Magento_Cms/layout/default.xml and check the situation once again.

Hope it will help.

Related Topic