The etc/adminhtml/menu.xml file is used to control the Magento 2 admin panel menu and add new items to it, in particular.
Create this file in your module folder, to add new menu element:
etc/adminhtml/menu.xml
and add the following code there:
<?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="VendorName_ModuleName::key1" title="Title 1" module="VendorName_ModuleName" parent="OtherVendorName_OtherModuleName::content" sortOrder="10" resource="VendorName_ModuleName::key1"/>
<add id="VendorName_ModuleName::key2" title="Title 2" module="VendorName_ModuleName" parent="VendorName_ModuleName::key1" sortOrder="10" action="path/controllerName" resource="VendorName_ModuleName::key2"/>
</menu>
</config>
id - a unique menu element identifier;
title - text of the element;
module - defines what module the element belongs to;
parent - identifier of the parent menu item;
sortOrder - position among other elements;
action - specifies the path which the element will be referenced to;
resource - acl (Access Control List) identifier, used to delimitate access rights (who can see this menu item). More information on the rights delimitation find in this article.
After saving the changes to menu.xml, clear the cache by running this CLI command:
php bin/magento cache:clean
Check the result.
In the examples, we create a module for FAQ. The modified module code can be viewed on GitHub.