I have added the below code to app/design/frontend/Company/Theme/Magento_Theme/layout/default.xml but the link is not appearing in the header. Can someone please tell me what I am missing?

       <referenceBlock name="header.links">
            <block class="Magento\Framework\View\Element\Html\Link" name="test.link" before="-">
                    <argument name="label" xsi:type="string" translate="false">test</argument>
                    <argument name="path" xsi:type="string" translate="false">test</argument>

I see you people making a custom block but I don't see why you cannot use the the native Link block.

2 Answers 2


I have added default.xml file with your given code on path app/code/Vender/Extension/view/frontend/layout/

And Happily, it's working and redirects to the given path "test".and also display heder link as "test".



Your code is working great and I also prefer the xml rather then html blocks. here is my screenshot, you can see you test link in the header.

  • sometime there is cache problem with magento, so please clear the cache, please use below two given commands and check again, it should work fine.

     php bin/magento cache:flush
     chmod -R 777 var/ generated/ pub/static/*

Please like if you find it useful. enter image description here

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.