In magento2 Layout updates are usually spread accross multiple files in your custom theme. e.g.


Is it good practice to put everything in Magento_Theme/layout/default.xml, and if not why?

For instance you could have have the below all in 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">
        <referenceBlock name="register-link" remove="true" /> <!-- This occurs on every page -->
        <referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/> <!-- This occurs on only on the account pages -->
        <referenceBlock name="product.info.review" remove="true" /> <!-- This occurs on only the product details page -->

If everything is put in one file, the default.xml, perhaps it's overkill as not all instructions are required for each page view or is the same layout file compiled and loaded for each page view, in which case it would make no difference.


The default.xml layout file is used in order to declare some layout instructions which are trigger on all pages.

If you need specific instruction for specific request, you need to put in the specific handle layout file.

The final layout file is generated and merged internally by Magento for each request, and so the default.xml instructions are always added to the merged result file.

Moreover, the default.xml can be located in the Theme module, but also in other module such as Catalog etc... All module layout files are parsed and merged in one file internally.

|improve this answer|||||
  • 1
    nice explanation! – JustinP Nov 7 '18 at 20:32

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.