0

How to add custom link (on custom module, not at theme) at header in magento 2

1 Answer 1

1

Create default.xml file in your custom module.

<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="Vendor_name\Module_name\Block\Link" name="some_link" before="-">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Custom link</argument>
                    <argument name="path" xsi:type="string">test</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

enter image description here

it will display in header links

2

Not the answer you're looking for? Browse other questions tagged or ask your own question.