Remove blocks or containers from layout magento2

Today i am explaining how to remove a block or container called by layout files.

Firstly you need to create layout file for the same controller.
for example : catalog_category_view.xml

Now add the line in your layout file:

<referenceBlock name="your block name" remove="true" />

in this, you can use referenceBlock for the blocks, and referenceContainer for the containers.
name, is the name of the block or container which you want to remove.
remove, is set to true to remove.

your file will be like this:

<?xml version="1.0"?>
<page xmlns:xsi="" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
		<referenceBlock name="content" remove="true" />

After flushing cache, the whole content container will get removed from category page.

Hope, this will helps you adding functionality in your module.

Thank you.

. . .


Add Your Comment

Be the first to comment.