As we know Magento 2 does not include features like adding extra(home, blog) links to main navigation menu. In this blog post we will discuss how to add non category links to navigation menu in Magento 2. In this we will use Magento 2 Observer page_block_html_topmenu_gethtml_before to add new link to menu.

Lets consider module with Namespace is Magewallet and Module Name is NavLinks. Lets list down all the files require for this extension.


First we will create registration file at app/code/Magewallet/NavLinks/registration.php file

Now, create a composer.json file in app/code/Magewallet/NavLinks/ folder as per below.

now create module.xml file in app/code/Magewallet/NavLinks/etc

now create events.xml file in app/code/Magewallet/NavLinks/etc/frontend

Now we will create Observer/Topmenu.php file.

Now run upgrade command php bin/magento setup:upgrade to install the module. Clear Magento 2 cache.

You have known all the steps to add new links to navigation menu of Magento 2. if you have any questions about this post, please ask them in comments.

Enjoy Magento 2! Enjoy Magewallet!!

Mahendra Paladiya
Mahendra is a Web Developer whose passions includes web development, technical blog writing, and database management. His passion for web development pushed him into learning how to handle different platforms like Core PHP, Magento, Prestashop, WordPress, CodeIgniter, CakePHP and Oracle.