Question

As the title. I've installed a fresh Magento CE 2.1.7

  • Opted out from installing sample data (no sample data)
  • Luma theme is selected by default (Luma logo appears)

Steps made:

  • Created a subcategory as sub-child of Default Category

  • Made sure both Default Category and subcategory are enabled from Admin >> Products >> Categories:

    Enable Category = Yes

    Include in Menu = Yes

  • Display Setting for category

    Anchor = Yes

enter image description here

  • Make sure Default Category is selected from Admin >> Stores >> All Stores >> Main Website Store

    Root Category = Default Category (selected from the drop-down)

  • I ran the following commands to clean cache and reindex:

    php bin/magento indexer:reindex;     
    rm -R pub/static/*;    
    rm -R var/view_preprocessed/*;     
    php bin/magento cache:flush;    
    php bin/magento cache:clean;
  • Purged and disabled Varnish cache on the server level
  • Restarted Apache
  • Upgraded Magento CE from 2.1.7 to 2.1.9

Expected result:

  • To see top navigation menu in all pages

Actual results (menu shows on all pages except home page):

  • Top navigation menu does not appear on Home Page

Picture 1. Homepage. Menu not showing:

enter image description here

  • Top navigation menu, however, appears correctly on other pages such as Customer Login and Create New Customer Account pages

Picture 2. Create a new customer account page. The menu is showing: enter image description here


I feel like I'm missing something obvious just under my nose.

How to display the top navigation menu on the home page?

Was it helpful?

Solution

After following major tutorials and troubleshooting web pages it turned out the issue lies with my hosting configuration.

Varnish Cache seems to be the cause of the menu disappearing. Disabling Varnish causes the menu to not show.

The solution is to enable Varnish Cache and the menu appeared again which is kinda bizarre for me and hard to understand.

enter image description here

Update:

It turns out there were different Vanish Cache on/off switches and I had them mixed up on/off.

-The first Varnish cache control I have is the main switch at the server level (from the interface of my hosting panel).

-The second one for application level (also from the interface of my hosting panel), which allows me to control enabling Varnish for individual applications on the server, rather than the whole server like in the main switch.

-The third one is from within Magento Admin (Magento 2 admin panel - configuration page).

I had my settings mixed up. (I cannot really remember by the time of writing this update) I think I had my Magento application Varnish settings enabled from Admin but disabled from the server or the application level.

Now if I want to use Varnish I make sure all settings are aligned. Switched on from top to bottom (server level to Magento level) and switch off from bottom to top.

OTHER TIPS

Take a look to this issue:

https://github.com/magento/magento2/issues/3421

Summary:

In some cases when Varnish Cache is activated, due to a Magento 2 and Varnish issue, the navigation menu can disappear.

In order to solve this Magento issue, you can remove the TTL attribute (remove ttl="3600") from /vendor/magento/module-theme/view/frontend/layout/default.xml, and the navigation menu will appear.

This is because varnish is disable from your server you need to follow these steps then your menu will appear

go into the store->configuration->Advanced->System->Full Page Cache enter image description here

and select the Built-in Cache and after then clear your admin cache then your menu will appear

please try these commands

  php bin/magento setup:static-content:deploy
  php bin/magento cache:clean
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top