I have added CMS page link to the top menu by following the below tutorial:


Since one of the custom menu items would be Home, so it should be the first item in the menu.

I want to know that how can I make some custom menu item as the first item in the top menu using the code in the tutorial.

Update: Suppose, I have 2 custom menu items, say Home and Contact. I want to make Home as the first menu item and Contact as the last menu item. Is it possible with a single plugin class? or I have to write 2 different plugins to achieve this goal?

Please help.

  • Need to change position of menu? Commented Jul 24, 2018 at 12:53
  • yes, I need to set the first position for the Home menu item. Commented Jul 24, 2018 at 13:00
  • With same way or any other way? Commented Jul 24, 2018 at 13:12

1 Answer 1


There is a issue with plugin order

In default Magento already plugin define in vendor/magento/module-catalog/etc/di.xml

<type name="Magento\Theme\Block\Html\Topmenu">
    <plugin name="catalogTopmenu" type="Magento\Catalog\Plugin\Block\Topmenu" />

And we created custom plugin in app\code{VendorName}{ModuleName}\etc\di.xml

<type name="Magento\Theme\Block\Html\Topmenu">
    <plugin name="add_cms_menu" type="{VendorName}{ModuleName}\Plugin\Topmenu" sortOrder="0" />

That means core and custom plugin, both are same exist with same sort order.

If you want to display custom menu just before category menu, sort order required minimum values to core value.

Use below code for plugin and check you custom menu

<type name="Magento\Theme\Block\Html\Topmenu">
    <plugin name="add_cms_menu" type="{VendorName}{ModuleName}\Plugin\Topmenu" sortOrder="-1" />

I hope it will be useful for you. Let me know if not working

  • Great. I did not think about this. One more question. I want to add Home at the first place and Contact Me at the last place. Is it possible with a single plugin? Commented Jul 24, 2018 at 14:02
  • If not, I will still upvote your answer. Commented Jul 24, 2018 at 14:03
  • Accept my answer if resolve current asked issue. Commented Jul 24, 2018 at 14:25
  • I have upvoted and accepted.Now can you answer on my question which I asked in the comment? Commented Jul 25, 2018 at 5:25
  • I have updated my question now. Commented Jul 25, 2018 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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