0

How can I add a Menu item in Magento 2 default Luma Theme ?

enter image description here

  • 1
    You can create child category or default category and then, it will display there. – Rohan Hapani Aug 9 at 4:13
  • Thanks @RohanHapani. What should I do if I would like to add a Static word ? – abu abu Aug 9 at 4:18
1

Static menu is not good practise. You should create sub menu in default category.

But, For static menu you need to overrride topmenu.phtml at app/design/frontend/<vendor_name>/<theme_name>/Magento_Theme/templates/html/

You can copy from your vendor/magento/module-theme/view/frontend/templates/html/topmenu.phtml and paste in your theme phtml like below way :

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

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

<nav class="navigation" data-action="navigation">
    <ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}'>
        <?= /* @escapeNotVerified */ $_menu ?>
        <?= /* @escapeNotVerified */ $block->getChildHtml() ?>
        <li class="level0 nav-7 category-item last level-top ui-menu-item" role="presentation">
            <a href="#" class="level-top ui-corner-all" id="ui-id-8" tabindex="-1" role="menuitem">
                <span>New Menu</span>
            </a>
        </li>
    </ul>
</nav>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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