How to Add Custom Admin Menu In Magento 2
In this article, We're going to explain you How to Add Custom Admin Menu In Magento 2. After following few simple steps of this article you are able to easily add your custom admin menu.
In our previous articles we've learn:
- How To Create Magento 2 Module
- How to Create Custom Database in Magento 2
- How to Insert Sample Data in Magento 2
- How to Create Model, Resource Model, and Collection in Magento 2
I hope you have understood and applied those steps easily. Now, before we create a UI Compoment Grid we need to create one custom admin menu for navigate to our custom grid. So, in this article, we will see how to create custom admin menu in Magento 2.
Let's get started!!
Follow the simple steps which are listed below.
First of all we need to Declare Route. To know more about Magento routing please review Magento official guide. As of now we are going to create route for admin area so we need to create routes.xml file under adminhtml folder.
Step 1: Create routes.xml at app/code/Devhooks/HelloWorld/etc/adminhtml/ and paste the below code.
saveCopyzoom_out_map<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
<router id="admin">
<route id="helloworld" frontName="helloworld">
<module name="Devhooks_HelloWorld" before="Magento_Backend"/>
</route>
</router>
</config>
Step 2: Create menu.xml file at app/code/Devhooks/HelloWorld/etc/adminhtml/ and paste the below code.
saveCopyzoom_out_map<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Devhooks_HelloWorld::helloworld" title="Vendor" module="Devhooks_HelloWorld" sortOrder="10"
resource="Devhooks_HelloWorld::helloworld"/>
<add id="Devhooks_HelloWorld::grid" title="Manage Grid" module="Devhooks_HelloWorld" sortOrder="10"
action="helloworld/index/index" resource="Devhooks_HelloWorld::grid" parent="Devhooks_HelloWorld::helloworld"/>
</menu>
</config>
Explanation of the entities used in the above code:
- id: is used as the unique identifier of a menu.
- title: the menu title that will be displayed in the admin menu.
- module: the module that I have created (Demo_Mymenu).
- sortOrder: is used to set the placement of menu.
- resource: a rule to identify which admin user can see this menu.
- action: is used to link an admin controller
- parent: is used to define which menu level it depends on.
Step 3: Now, open Command line in folder root of magento and run both commands
saveCopyzoom_out_mapphp bin/magento cache:clean
Log in to the admin of your Magento 2 and you will see the new menu like the below screenshot.

That's it.
We have successfully created new custom menu, we hope this article helped you to know How to Add Custom Admin Menu In Magento 2. Now, let's move to the next step to know How to Create UI Component Grid In Magento 2 .
Stay Tuned...
Bookmark it for your future reference. Do comment below if you have any other questions or doubts.
P.S. Do share this post with your team.
Special thanks to Rutvik Monpara, He helped me a lot to write a series of How to Create UI Component Grid and Form in Magento 2.
AI-Powered Recommended Articles
How to Create UI Component Grid In Magento 2
Learn how to create a custom UI component grid in Magento 2 for enhanced administrative functionality.
How to Create UI Component Form and CRUD Operation In Magento 2
Learn how to create UI component forms and implement CRUD operations in Magento 2 for efficient backend management.
How To Create Magento 2 Module with Admin Grid and Form using UI Component
Learn how to create a custom Magento 2 module with an admin grid and form using UI components.
How to Add Mass Action in UI Component Grid in Magento 2
Learn how to add mass actions to Magento 2 UI component grids to enhance administrative efficiency.
How to Create Model, Resource Model, and Collection in Magento 2
Step-by-step guide to creating a model, ResourceModel, and collection in Magento 2 for custom data handling.
Magento 2 - How to Add a Custom Link in Admin Order Listing Grid Page
Learn how to add a custom link to the admin order listing page in Magento 2 for enhanced order management.