Is there a way to hide the Compare and Wishlist blocks on the front-end (in the navigation) when they are not in use?


You can override the block using below file and can remove that using xml:


By adding default.xml you can remove that, In your theme:


<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="wishlist_sidebar" remove="true" />
        <referenceBlock name="catalog.compare.sidebar" remove="true"/> 
  • Thanks for the answer. But I think I didn't explain it very well. The meaning is that when they are used (active). Thay they become visible in the sidebar if not, that they are not visible in the sidebar – Paul Kuijten May 7 '19 at 6:55
  • ok, for that you should count the number of item in that, if it is 0 then hide it. – Saphal Jha May 7 '19 at 6:58
  • Can you provide me with the code please, i donw't want to make a mistake :) – Paul Kuijten Sep 16 '19 at 8:26

For wish List you can disabled via Admin

Stores => Configuration => Customers => Wish list => General Options > Enabled = No

For Compare you can hide via xml:

<referenceBlock name="catalog.compare.sidebar" remove="true"/> 

Not the answer you're looking for? Browse other questions tagged or ask your own question.