1
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <!--Add Logo-->
            <referenceBlock name="logo">
                <arguments>
                    <argument name="logo_width" xsi:type="number">100</argument> 
                    <argument name="logo_height" xsi:type="number">100</argument>
                    <argument name="logo_file" xsi:type="string">images/logo.jpg</argument>
                </arguments>
            </referenceBlock>

       <referenceBlock name="header.panel">

            <block class="Magento\Framework\View\Element\Html\Link" name="top.links" after="authorization-link">
                <arguments>
                    <argument name="label" xsi:type="string" translate="true">Checkout</argument>
                    <argument name="path" xsi:type="string" translate="true">checkout</argument>

                </arguments>
            </block>

             <!--  you can easly Remove  links with following code -->
            <referenceBlock name="register-link" remove="true" />   
            <referenceBlock name="wish-list-link" remove="true" />   
            <referenceBlock name="my-account-link" remove="true" />         
            <referenceBlock name ="footer" remove="true" />                

</referenceBlock>

    </body>
</page>

1 Answer 1

0

So simple and easy way is create custom small custom module and create header Link.

Step 1: Add default.xml file

Find the path app/code/module_vendor/module_name/view/frontend/layout, then add default.xml file by:

<?xml version="1.0"?>
<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="module_vendor\module_name\Block\Link" name="add-new-header-link">
             <arguments>
     <argument name="label" xsi:type="string" translate="true">New Link</argument>
     <argument name="path" xsi:type="string" translate="true">new-link</argument>
     </arguments>
         </block>
     </referenceBlock>
</body>

Step 2: Add Link.php file

Continue with the path app/code/module_vendor/module_name/Block and you will add the link.php file:

<?php

namespace module_vendor\module_name\Block;

class Link extends \Magento\Framework\View\Element\Html\Link
{
protected function _toHtml()
    {
     if (false != $this->getTemplate()) {
     return parent::_toHtml();
     }
     return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
    }
}

And Your above code remove and write this code UPDATE:-

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

Step 3: Run Some commands like :-

php bin/magento c:c
php bin/magento c:f

Hope this help you

Thanks ...

14
  • Thank you .What's the location of link .php
    – tamanna
    Jun 10, 2020 at 9:48
  • Ohh,sorry module_vendor\module_name\Block\Link.php Jun 10, 2020 at 9:51
  • i have updated the my answer... Jun 10, 2020 at 10:06
  • okay i will try this
    – tamanna
    Jun 10, 2020 at 10:21
  • It does not work.
    – tamanna
    Jun 10, 2020 at 10:35

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.