Magento 2 Customization – How to Add Custom Top Links

layoutmagento2templatetoplinks

Hello Can you help me on how to add custom top links in the header area of Magento 2,

Like this: Header Links

Best Answer

You can manage this using Static Block. In your theme default.xml you can add new static block.
File Path : Custom\tutorial\Magento_Theme\layout\default.xml

<referenceBlock name="header.panel">
<block class="Magento\Cms\Block\Block" name="header_promo_top">
    <arguments>
        <argument name="block_id" xsi:type="string">header_promo_top</argument>
    </arguments>
</block>
</referenceBlock>

Here header_promo_top is your static block that will contain your content.

Magento 2 default theme usesheader.panel Container for showing languages switcher and skip content block in Top bar. You can get more idea about this using the below file:
vendor\magento\module-theme\view\frontend\layout\default.xml

Related Topic