- 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
<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>
No comments:
Post a Comment