Magento 2 – Navigation Links for CMS Pages

magento2navigationtoplinks

I've been trying to figure out how to add links to the top navigation for Magento 2.

In 1.x we'd just URL rewrites, however, that doesn't seem to work in Magento 2.x at this point. I added a new category Home. Then, I went to: Marketing > URL Rewrites, and edited the URL rewrite (changing the Redirect Type to 301) and saved it. Next, I clicked Add URL Rewrite, type Custom and used request path of "catalog/category/view/id/23" and target path /. I tried the redirect type as none and 301.

Is this done differently in Magento 2? Or is there another way to add links to the top navigation menu ? My problem is, I don't just need to add one link, I need to add multiple links, and they need to be drop-downs.

Best Answer

1- Create topmenu.phtml in design/frontend/magento/you_theme/Mageto_Theme/templates/html/topmenu.phtml

<?php
/**
 * Top menu for store
 *
 * @see \Magento\Theme\Block\Html\Topmenu
 */
?>
<?php $columnsLimit = $block->getColumnsLimit() ?: 0; ?>
<?php $_menu = $block->getHtml('level-top', 'submenu', $columnsLimit) ?>

<nav class="navigation" role="navigation">
    <ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'>
        <?php /* @escapeNotVerified */ echo $_menu; ?>
        something...
    </ul>
</nav>

2- Refresh cache