How to Remove Blocks or Containers From Layout in Magento 2?

How to Remove Block or Container From Layout in Magento 2?

Magento provides flexibility to update page designs as per business requirements to improve customer experience. As a part of this, we may be required to remove blocks or containers from specific layout files in Magento.

In Magento 2 layouts, you can easily remove a specific block or container using the magical “remove” attribute.

You can use referenceBlock for the blocks, and referenceContainer for the containers.

Syntax :

Suppose there is a requirement to remove footer links from all the pages.

The footer links come from the block “footer_links“, so we can specify below the line in the default.xml if we want to remove footer links from all pages.

above code will remove footer links from the footer. If you want to remove a specific footer link you can specify those using the block name of the links as shown below.

You may also like :

How to use ifconfig in layout xml Magento 2?

That’s it for this tutorial, See you in the next blog. Happy Coding 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *