Remove blocks or containers from a layout in Magento 2

Posted on: July 22, 2019
Blog Frontend Magento

Here’s a quick example of how to remove a block or a container called by the layout files, via XML. It’s a simple and quick way to remove items from the page in Magento 2 and can be a very handy way to enhance a Users Experience.

Let’s get started. If you don’t already have the following file:


Go ahead and make it in your theme.

<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">    

Now inside of this file, add the following line inside of your <body> tags:

<referenceBlock name="your_block_selector" remove="true" />

In this example, I’ve shown how you can remove a Block from the layout, however, the same principle can be achieved with referenceContainer. By replacing the referenceBlock at the start with referenceContainer.

Time to flush the cache and the block or container you wanted to remove will be gone.


Hopefully, this little tutorial will help you achieve a quick and easy route to removing unused blocks or containers on your Magento 2 page.

Here at aware, we create bespoke eCommerce websites that convert and drive sales. With bespoke theme’s built just for you. Get in touch.

Northern Digital Shortlisted
Northern Digital Shortlisted
Posted on: December 6, 2019

Today we’ve been shortlisted for a Northern Digital Award on our work on a current client of ours, Nemesis Now. We couldn’t be happier with the site and neither could Nemesis Now Let’s hope we win. Short and sweet…

Read more
Stop People Copying Your Content with only HTML & CSS
Stop People Copying Your Content with only HTML & CSS
Posted on: November 27, 2019

Stopping people from copying content from your website isn’t the best idea. But, people do opt to do it. Usually, people will go for the simple approach of using Javascript. But I’m going to…

Read more
Magento, why you should upgrade your store.
Magento, why you should upgrade your store.
Posted on: November 21, 2019

Taking the step from Magento 1 to Magento 2 might seem daunting, but once you’ve migrated to Magento 2 you’ll be taking advantage of the latest features and functionality. Updating to Magento 2 also…

Read more