In magento2 Layout updates are usually spread accross multiple files in your custom theme. e.g.
Magento_Catalog/layout/catalog_product_view.xml Magento_Theme/layout/default.xml Magento_Customer/layout/customer_account.xml
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"> <body> <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 --> </body> </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.