Skip to content

Instantly share code, notes, and snippets.

@ErMandeep
Created June 10, 2021 06:54
Show Gist options
  • Save ErMandeep/87d7674f2a1b8a8ce6eb1a11eba30ddf to your computer and use it in GitHub Desktop.
Save ErMandeep/87d7674f2a1b8a8ce6eb1a11eba30ddf to your computer and use it in GitHub Desktop.
How to add custom link in main menu in Magento 2?
https://www.google.com/search?q=how+to+add+custom+link+in+navigation+menu+in+magento2&rlz=1C5CHFA_enIN912IN912&sxsrf=ALeKk02vfjQFF_fgAESf1aOwu46NOatT3A%3A1623299562587&ei=6pXBYN3BI-_Wz7sPw-eykAk&oq=add+custom+link+in+magento+2+in+child+theme&gs_lcp=Cgdnd3Mtd2l6EAMYAjIHCCMQsAMQJzIHCAAQRxCwAzIHCAAQRxCwAzIHCAAQRxCwAzIHCAAQRxCwAzIHCAAQRxCwAzIHCAAQRxCwAzIHCAAQRxCwAzIHCAAQRxCwA1AAWABgs1VoAXACeACAAewBiAHsAZIBAzItMZgBAKoBB2d3cy13aXrIAQnAAQE&sclient=gws-wiz
@ErMandeep
Copy link
Author

copy file from

vendor/magento/module-theme/view/frontend/templates/html/topmenu.phtml

and put this file in your theme location

app/design/frontend/Vendor/YourTheme/Magento_Theme/templates/html/topmenu.phtml

Add below

  • structure just after getChildHtml(); ?> line in topmenu.phtml

    <li class="level0 level-top ui-menu-item">
        <a href="<?php echo $this->getBaseUrl()."yourlink"; ?>" class="level-top ui-corner-all"  role="menuitem">
            <span><?php echo __("Your Custom Menu")?></span>
        </a>
    </li>
    
  • Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment