Magento 2 – Move Navigation Sections into Page Header Element in XML

magento2xml

This is my code:

    <move element="navigation.sections" destination="page.header" />

But the navigation bar disappears then. Whats wrong here?

Best Answer

Solution was to use header.container. Found it via console:

grep -rl "navigation.sections" * to find out where this gets injected, because its close to the desired destination.

nano vendor/magento/module-theme/view/frontend/layout/default.xml to find the name of the container in which it gets injected. Suprise - its header.container instead of page.header.

 <move element="navigation.sections" destination="header.container" />