Solved: Navigation / Mega Menu is Missing When Varnish Cache is Activated in Magento 2
Megamenu is a drop-down menu with multi-level expansions that lets you display your website’s full navigation into a single menu. A mega menu allows visitors to reach even the deepest sections of a website through the main menu.
Megamenu is one of the most beneficial aspects to improve user experience as Jakob Nielsen explains, “By helping users find more, they’ll help you sell more.”
The mega menu navigation can disappear in some cases. One of the issues is when you activate the varnish cache in your Magento 2 store; the mega menu may disappear.
In those cases, use the below solution to show the mega menu in Magento 2 store.
Solution for Navigation / Mega Menu is Missing When Varnish Cache is Activated in Magento 2:
Remove the TTL attribute (ttl=”3600″) from default.xml file located at vendor/magento/module-theme/view/frontend/layout.
1 2 3 4 5 6 |
<block class="Magento\Framework\View\Element\Template" name="store.menu" group="navigation-sections" template="Magento_Theme::html/container.phtml"> <arguments> <argument name="title" translate="true" xsi:type="string">Menu</argument> </arguments> <block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav" template="Magento_Theme::html/topmenu.phtml" ttl="3600" before="-"/> </block> |
Now check in the frontend, Megamenu is now displaying in your store!
That’s easy, right? You can fixnavigation menu not showing in Magento 2 error, as top navigation menu makes it easy for visitors to navigate through the Magento 2 store.
If you have any doubts regarding this post, just mention them in the Comments section below.
I would be happy to help.
Feel free to share the solution with Magento Community via social media.
Thank You.
2 Comments
hi we did follow the above mentioned advice but no luck, we still not able to see the menu while the varnish is ON
please advise
Thanks
Sid
Hello Siddharth,
It only works if the varnish cache is in your server.
It may be the theme issue. However, this solution works fine from our end.
Thank You.