1

I would like to add a custom top link which redirects to external URL like Google.com or a blog link etc.

I added the custom top link using referencecontainerBlock. However, I'm not sure where should I give the link for external URL which I would like to re-direct.

<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>
        </arguments>
    </block>
</referenceBlock>

Pls advise.

1
  • can you please share code, where and how you add link.
    – Pawan
    Aug 13, 2017 at 2:33

1 Answer 1

3

You can use path argumnet to give external link like this:

<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"><![CDATA[http://www.google.com]]></argument>
    </arguments>
</block>
1
  • so needed that, thank you ! (cuz natively it parses the path using UrlBuilder)
    – medmek
    Feb 4, 2020 at 23:20

Your Answer

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

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