Magento2 add a cms page link to menu

Magento2 add a cms page link to menu

.
Magento2 add a cms page link to menu or Magento2 add a custom link to the menu, Magento2 add a cms page link at menu.
We have seen Magento1.Most of the times, need to add cms page links to the menu.

So, today I am writing a blog where add cms page link to the menu at magento2 .This also works for Magento 2 Add cms static page to navigation.

For this, we are going to use a plugin for class Magento\Theme\Block\Html\Topmenu.

and use before plugin on _getHtml()

First, create a module.

Second: create di.xml where  we will define plugin

app\code\{VendorName}\{ModuleName}\etc\di.xml

Third: Now create the plugin class where we will add a cms page link to menu.

and also  in this way we can add a cms page link at navigation.

app\code\{VendorName}\{ModuleName}\Plugin\Topmenu.php

 

In this way, you can Magento2 an add custom link to menu or navigation.

 

 

In this example, I have added contact us page to the menu.

Hope this blog will help the people.

 

Related posts:

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *