Steps to add custom link for CMS page in magento 2 header are as under
-
First create a CMS page for example we will create an about us page with identifier as “about-us”.
-
Now usually, to access the cms page in frontend, we use www.domain.com/{identifier}
-
So, the top link that we will add for the about us page should redirect to www.domain.com/about-us
-
To add the top link, we will add following code in default.xml of our theme
Path to the file: app/design/frontend/Magento/themename\Magento_Theme\layout\default.xml
1 2 3 4 5 6 7 8 |
<referenceBlock name="top.links"> <block class="Magento\Framework\View\Element\Html\Link\Current" name="about-us"> <arguments> <argument name="label" xsi:type="string">About Us</argument> <argument name="path" xsi:type="string">about-us</argument> </arguments> </block> </referenceBlock> |
For your example, How can i Add ‘image icon’ next to ‘About-us’ on default.xml?