2

I tried to override the app/design/frontend/Vendor/MyTheme/Magento_Theme/layout/default.xml, but it doesn't show any changes. I want to add custom links in top.links of parent theme (blank theme):

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="top.links">
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="contact-us">
            <arguments>
                <argument name="label" xsi:type="string">Contact Us</argument>
                <argument name="path" xsi:type="string">contact-us</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>

Like here: http://www.webmull.com/how-to-add-custom-top-links-in-magento-2-header/

I've flushed the cache, but it doesn't show any custom link.

Thank for your help.

3

there is one minor mistakes in your code

 <block class="Magento\Framework\View\Element\Html\Link\Current" name="contact-us">

Replace your block name "Contact-us" to "contactus.link"

below is the correct code please review

for extended Blank Theme

app/design/frontend/Amydus/test/Magento_Theme/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
       <!--  you can easly add New links with following code -->
        <referenceBlock name="top.links">
               <!-- Contact us Link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="contactus.link" after="register-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">Constact Us</argument>
                    <argument name="path" xsi:type="string" translate="false">contact-us</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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