0

I am trying to add custom header link, but it is not showing.

1

2 Answers 2

0

To add custom Header Link :

Create a default.xml file in the below path.

app/code/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml

Add the Below Code.

<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="custom-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Custom Link</argument>
                <argument name="path" xsi:type="string" translate="true">customlinkpath</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>

0

If you want to add link in main menu then please follow below steps

Create a default.xml file on below path

app/code/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml

Add below code

<referenceBlock name="catalog.topnav">
    <block class="Magento\Cms\Block\Block" name="static_page_top_menu">
        <arguments>
            <argument name="block_id" xsi:type="string">static_page_top_menu</argument>
        </arguments>
    </block>
</referenceBlock>

Create new CMS block and add below code

<ul class="static-menu">
    <li class="level0 nav-5 last level-top ui-menu-item"><a class="level-top ui-corner-all" href="{{store direct_url=""}}">Custom Link</a>
    </li>
</ul>

Please Add bellow css according to your design

.navigation ul.static-menu {
    display: inline-block !important;
    position: static;
}
.navigation ul.static-menu .level0  .level-top {
    border:0;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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