How to Add Non-Category Link to Navigation Links in Magento 2

- Fire development, Magento 2

Magento 2 Development; Magento 2 tutorial

The following article sheds light on how to add a non-category link to navigation links in Magento 2. If you are not sure what to do, you’ve come to the right place, because below we detailly discuss this problem.

'

If you still think that the block which holds the category links in can be referenced to as navigation.sections and the following arguments can be directed towards the container providing the ability to create a new link under it, you are mistaken.

The latest Magento 2 version doesn’t support this approach anymore. But you can still achieve your goal!

It is necessary to replace an observer with a plugin for Magento\Theme\Block\Html\Topmenu.

  1. Find the etc/frontend/di.xml file.
  2. Add the following code to it:

  1. Create the plugin class file [Namespace]/[Module]/Plugin/Block/Topmenu.php.
  2. Add the following content:

This is the fastest way of adding a non-category link to navigation links in Magento 2. We hope the article was useful. It is based on the StackExchange question by Themanwhoknowstheman and the answer by Mariusand Darren Felton. For more useful articles, check out our Cookbook.

'