Request Quote Demos

Header and Top links in Magento 2

In this blog I will explain how to add header and top link with default.xml file. Header link is displayed for both guest and logged in customers. Top link is displayed only for logged in users.

To show the links create default.xml under Webkul/Menu/view/frontend/layout folder

<?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>
        <referenceBlock name="header.links">
            <block class="Magento\Framework\View\Element\Html\Link" name="header-menu">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Header Menu</argument>
                    <argument name="path" xsi:type="string">*/*/*</argument>
                </arguments>
            </block>
        </referenceBlock>
        <referenceBlock name="top.links">
            <block class="Magento\Framework\View\Element\Html\Link" name="top-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Top Link</argument>
                    <argument name="path" xsi:type="string">*/*/*</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

 

For guest customer, 

 

For Logged in customer,

 

Check out the following blogs regarding links,

Add Custom Block and Link Header in Magento 2

How to add custom link in navigation menu in Magento2

Magento2 – Add New Link in My Account Navigation Panel

call custom block and links in footer in magento 2

 

Feel free to comment if any issue occurs.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php