Hello friends, I am going to share How To Add Custom Menu Link in Top Menu Section ( Main Top )Magento 2 Frontend , my best megento practice with you guys through this post. And I hope that through this post you will get a lot of help in customizing the megento ecomm platform.
Here My Vendor_Name : Mageget
Here My Module_Name : CategoryAttribute
1) Create a module.xml file in - \app\code\Mageget\CategoryAttribute\etc\module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mageget_CategoryAttribute" setup_version="1.0.2">
<sequence>
<module name="Magento_Catalog"/>
<module name="Magento_Backend"/>
</sequence>
</module>
</config>
2) Create a registration.php file in - \app\code\Mageget\CategoryAttribute\registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Mageget_CategoryAttribute',
__DIR__
);
3) Create a default.xml file in - \app\code\Mageget\CategoryAttribute\view\frontend\layout\default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<!-- Code for Header Link -->
<referenceBlock name="header.links">
<block class="Magento\Framework\View\Element\Html\Link" name="blog-header-menu">
<arguments>
<argument name="label" xsi:type="string" translate="true">Blogs</argument>
<argument name="path" xsi:type="string">blog</argument>
</arguments>
</block>
</referenceBlock>
<!-- Code for Footer Link -->
<referenceBlock name="footer_links">
<block class="Magento\Framework\View\Element\Html\Link" name="blog-footer-menu">
<arguments>
<argument name="label" xsi:type="string" translate="true">Blogs</argument>
<argument name="path" xsi:type="string">blog</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>