In magento 2.0 how can i add new top links and remove existing one using xml

If you extended Luma 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="header.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>
            <!-- CMS Page Link Link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="aboutus.link" after="contactus.link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">about Us</argument>
                    <argument name="path" xsi:type="string" translate="false">about-us</argument>
                </arguments>
            </block>

             <!--  you can easly Remove  links with following code -->
            <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
            <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
            <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
            <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->

        </referenceBlock>
    </body>
</page>

If you 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>
            <!-- CMS Page Link Link -->
            <block class="Magento\Framework\View\Element\Html\Link" name="aboutus.link" after="contactus.link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="false">about Us</argument>
                    <argument name="path" xsi:type="string" translate="false">about-us</argument>
                </arguments>
            </block>

             <!--  you can easly Remove  links with following code -->
            <referenceBlock name="register-link" remove="true" />           <!--for Create Account Link-->
            <referenceBlock name="authorization-link" remove="true" />      <!--for Sign In Link  -->
            <referenceBlock name="wish-list-link" remove="true" />          <!--for WishList Link-->
            <referenceBlock name="my-account-link" remove="true" />         <!--for My Account Link-->

        </referenceBlock>
    </body>
</page>

You can also use the Magento\Customer\Block\Account\SortLinkInterface block class, which allows you to sort links in the top.links block.

<referenceBlock name="top.links">
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="newsletter_subscription_top_link">
    <arguments>
        <argument name="label" xsi:type="string" translate="true">Newsletter Subscription</argument>
        <argument name="path" xsi:type="string" translate="true">newsletter/manage</argument>
        <argument name="sortOrder" xsi:type="number">10</argument>
    </arguments>
</block>
</referenceBlock>

Tags:

Magento 2.0