How can add link in Header link Before the Welcome Message in magento 2












3















enter image description here



How can add a custom page link in the header Before the Welcome Message










share|improve this question




















  • 2





    I donot think this is a duplicated answer

    – Amit Bera
    16 hours ago
















3















enter image description here



How can add a custom page link in the header Before the Welcome Message










share|improve this question




















  • 2





    I donot think this is a duplicated answer

    – Amit Bera
    16 hours ago














3












3








3








enter image description here



How can add a custom page link in the header Before the Welcome Message










share|improve this question
















enter image description here



How can add a custom page link in the header Before the Welcome Message







magento2 headerlink






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 16 hours ago









Amit Bera

59.2k1575177




59.2k1575177










asked 16 hours ago









HaFiz UmerHaFiz Umer

3289




3289








  • 2





    I donot think this is a duplicated answer

    – Amit Bera
    16 hours ago














  • 2





    I donot think this is a duplicated answer

    – Amit Bera
    16 hours ago








2




2





I donot think this is a duplicated answer

– Amit Bera
16 hours ago





I donot think this is a duplicated answer

– Amit Bera
16 hours ago










4 Answers
4






active

oldest

votes


















1














Please check on below URL. it shows how to add custom blog link.



Let me know if it helps.



https://zemez.io/magento/support/how-to/magento-2-1-x-manage-top-header-links/



Also, need to update theme default.xml file with below code.



<referenceBlock name="header.panel">
<block class="MagentoCmsBlockBlock" name="header_promo_top">
<arguments>
<argument name="block_id" xsi:type="string">header_promo_top</argument>
</arguments>
</block>
</referenceBlock>





share|improve this answer





















  • 2





    Please donot p put a single link answer.Answer must has some content

    – Amit Bera
    16 hours ago











  • @AmitBera, Thank you. i will take care from next time.

    – Yogesh
    15 hours ago



















2














Step 1: create a CMS page. For example, we create a “Custom Link” page with an URL such as http://localhost/custom_link



Step 2: Create a default.xml file in the following path: appcodeVendorModuleviewfrontendlayout with the following content:



<?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=”Vendor_nameModule_nameBlockLink" name="some_link" >
<arguments>
<argument name="label" xsi:type="string" translate="true">Custom link</argument>
<argument name="path" xsi:type="string">test</argument>
</arguments>
</block>
</referenceBlock>
</body>




Step 3: Create the Block class Link with the following content:



<?php
namespace VendorModuleBlock;
class Link extends MagentoFrameworkViewElementHtmlLink
{
/**
* Render block HTML.
*
* @return string
*/
protected function _toHtml()
{
if (false != $this->getTemplate()) {
return parent::_toHtml();
}
return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
}
}


I hope it helps!






share|improve this answer































    1














    Add this code in default.xml



     <referenceBlock name="header.links">
    <block class="MagentoCustomerBlockAccountRegisterLink" name="register-link-new" after="-">
    <arguments>
    <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
    </arguments>
    </block>
    <block class="VendorModuleBlockToplink" name="add.subscriptionplan.top" ifconfig="Vendor_Module/general/enable" after="-" />
    </referenceBlock>
    <referenceBlock name="register-link" remove="true"/>





    share|improve this answer































      1














      @Chirag Patel code almost right.



      Only have to add below code after



      <move element="some_link" destination="header.links" before="-"/>



      or



      <move element="some_link" destination="header.links" before="header"/>


      after </referenceBlock> tab on default.xml.



      It will move your link at first






      share|improve this answer
























      • Thanks @Amit Bera for make good answer to perfect answer. +1 for this. :)

        – Chirag Patel
        15 hours ago











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "479"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266268%2fhow-can-add-link-in-header-link-before-the-welcome-message-in-magento-2%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Please check on below URL. it shows how to add custom blog link.



      Let me know if it helps.



      https://zemez.io/magento/support/how-to/magento-2-1-x-manage-top-header-links/



      Also, need to update theme default.xml file with below code.



      <referenceBlock name="header.panel">
      <block class="MagentoCmsBlockBlock" name="header_promo_top">
      <arguments>
      <argument name="block_id" xsi:type="string">header_promo_top</argument>
      </arguments>
      </block>
      </referenceBlock>





      share|improve this answer





















      • 2





        Please donot p put a single link answer.Answer must has some content

        – Amit Bera
        16 hours ago











      • @AmitBera, Thank you. i will take care from next time.

        – Yogesh
        15 hours ago
















      1














      Please check on below URL. it shows how to add custom blog link.



      Let me know if it helps.



      https://zemez.io/magento/support/how-to/magento-2-1-x-manage-top-header-links/



      Also, need to update theme default.xml file with below code.



      <referenceBlock name="header.panel">
      <block class="MagentoCmsBlockBlock" name="header_promo_top">
      <arguments>
      <argument name="block_id" xsi:type="string">header_promo_top</argument>
      </arguments>
      </block>
      </referenceBlock>





      share|improve this answer





















      • 2





        Please donot p put a single link answer.Answer must has some content

        – Amit Bera
        16 hours ago











      • @AmitBera, Thank you. i will take care from next time.

        – Yogesh
        15 hours ago














      1












      1








      1







      Please check on below URL. it shows how to add custom blog link.



      Let me know if it helps.



      https://zemez.io/magento/support/how-to/magento-2-1-x-manage-top-header-links/



      Also, need to update theme default.xml file with below code.



      <referenceBlock name="header.panel">
      <block class="MagentoCmsBlockBlock" name="header_promo_top">
      <arguments>
      <argument name="block_id" xsi:type="string">header_promo_top</argument>
      </arguments>
      </block>
      </referenceBlock>





      share|improve this answer















      Please check on below URL. it shows how to add custom blog link.



      Let me know if it helps.



      https://zemez.io/magento/support/how-to/magento-2-1-x-manage-top-header-links/



      Also, need to update theme default.xml file with below code.



      <referenceBlock name="header.panel">
      <block class="MagentoCmsBlockBlock" name="header_promo_top">
      <arguments>
      <argument name="block_id" xsi:type="string">header_promo_top</argument>
      </arguments>
      </block>
      </referenceBlock>






      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 15 hours ago

























      answered 16 hours ago









      YogeshYogesh

      307211




      307211








      • 2





        Please donot p put a single link answer.Answer must has some content

        – Amit Bera
        16 hours ago











      • @AmitBera, Thank you. i will take care from next time.

        – Yogesh
        15 hours ago














      • 2





        Please donot p put a single link answer.Answer must has some content

        – Amit Bera
        16 hours ago











      • @AmitBera, Thank you. i will take care from next time.

        – Yogesh
        15 hours ago








      2




      2





      Please donot p put a single link answer.Answer must has some content

      – Amit Bera
      16 hours ago





      Please donot p put a single link answer.Answer must has some content

      – Amit Bera
      16 hours ago













      @AmitBera, Thank you. i will take care from next time.

      – Yogesh
      15 hours ago





      @AmitBera, Thank you. i will take care from next time.

      – Yogesh
      15 hours ago













      2














      Step 1: create a CMS page. For example, we create a “Custom Link” page with an URL such as http://localhost/custom_link



      Step 2: Create a default.xml file in the following path: appcodeVendorModuleviewfrontendlayout with the following content:



      <?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=”Vendor_nameModule_nameBlockLink" name="some_link" >
      <arguments>
      <argument name="label" xsi:type="string" translate="true">Custom link</argument>
      <argument name="path" xsi:type="string">test</argument>
      </arguments>
      </block>
      </referenceBlock>
      </body>




      Step 3: Create the Block class Link with the following content:



      <?php
      namespace VendorModuleBlock;
      class Link extends MagentoFrameworkViewElementHtmlLink
      {
      /**
      * Render block HTML.
      *
      * @return string
      */
      protected function _toHtml()
      {
      if (false != $this->getTemplate()) {
      return parent::_toHtml();
      }
      return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
      }
      }


      I hope it helps!






      share|improve this answer




























        2














        Step 1: create a CMS page. For example, we create a “Custom Link” page with an URL such as http://localhost/custom_link



        Step 2: Create a default.xml file in the following path: appcodeVendorModuleviewfrontendlayout with the following content:



        <?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=”Vendor_nameModule_nameBlockLink" name="some_link" >
        <arguments>
        <argument name="label" xsi:type="string" translate="true">Custom link</argument>
        <argument name="path" xsi:type="string">test</argument>
        </arguments>
        </block>
        </referenceBlock>
        </body>




        Step 3: Create the Block class Link with the following content:



        <?php
        namespace VendorModuleBlock;
        class Link extends MagentoFrameworkViewElementHtmlLink
        {
        /**
        * Render block HTML.
        *
        * @return string
        */
        protected function _toHtml()
        {
        if (false != $this->getTemplate()) {
        return parent::_toHtml();
        }
        return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
        }
        }


        I hope it helps!






        share|improve this answer


























          2












          2








          2







          Step 1: create a CMS page. For example, we create a “Custom Link” page with an URL such as http://localhost/custom_link



          Step 2: Create a default.xml file in the following path: appcodeVendorModuleviewfrontendlayout with the following content:



          <?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=”Vendor_nameModule_nameBlockLink" name="some_link" >
          <arguments>
          <argument name="label" xsi:type="string" translate="true">Custom link</argument>
          <argument name="path" xsi:type="string">test</argument>
          </arguments>
          </block>
          </referenceBlock>
          </body>




          Step 3: Create the Block class Link with the following content:



          <?php
          namespace VendorModuleBlock;
          class Link extends MagentoFrameworkViewElementHtmlLink
          {
          /**
          * Render block HTML.
          *
          * @return string
          */
          protected function _toHtml()
          {
          if (false != $this->getTemplate()) {
          return parent::_toHtml();
          }
          return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
          }
          }


          I hope it helps!






          share|improve this answer













          Step 1: create a CMS page. For example, we create a “Custom Link” page with an URL such as http://localhost/custom_link



          Step 2: Create a default.xml file in the following path: appcodeVendorModuleviewfrontendlayout with the following content:



          <?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=”Vendor_nameModule_nameBlockLink" name="some_link" >
          <arguments>
          <argument name="label" xsi:type="string" translate="true">Custom link</argument>
          <argument name="path" xsi:type="string">test</argument>
          </arguments>
          </block>
          </referenceBlock>
          </body>




          Step 3: Create the Block class Link with the following content:



          <?php
          namespace VendorModuleBlock;
          class Link extends MagentoFrameworkViewElementHtmlLink
          {
          /**
          * Render block HTML.
          *
          * @return string
          */
          protected function _toHtml()
          {
          if (false != $this->getTemplate()) {
          return parent::_toHtml();
          }
          return '<li><a ' . $this->getLinkAttributes() . ' >' . $this->escapeHtml($this->getLabel()) . '</a></li>';
          }
          }


          I hope it helps!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 16 hours ago









          Chirag PatelChirag Patel

          2,348423




          2,348423























              1














              Add this code in default.xml



               <referenceBlock name="header.links">
              <block class="MagentoCustomerBlockAccountRegisterLink" name="register-link-new" after="-">
              <arguments>
              <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
              </arguments>
              </block>
              <block class="VendorModuleBlockToplink" name="add.subscriptionplan.top" ifconfig="Vendor_Module/general/enable" after="-" />
              </referenceBlock>
              <referenceBlock name="register-link" remove="true"/>





              share|improve this answer




























                1














                Add this code in default.xml



                 <referenceBlock name="header.links">
                <block class="MagentoCustomerBlockAccountRegisterLink" name="register-link-new" after="-">
                <arguments>
                <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
                </arguments>
                </block>
                <block class="VendorModuleBlockToplink" name="add.subscriptionplan.top" ifconfig="Vendor_Module/general/enable" after="-" />
                </referenceBlock>
                <referenceBlock name="register-link" remove="true"/>





                share|improve this answer


























                  1












                  1








                  1







                  Add this code in default.xml



                   <referenceBlock name="header.links">
                  <block class="MagentoCustomerBlockAccountRegisterLink" name="register-link-new" after="-">
                  <arguments>
                  <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
                  </arguments>
                  </block>
                  <block class="VendorModuleBlockToplink" name="add.subscriptionplan.top" ifconfig="Vendor_Module/general/enable" after="-" />
                  </referenceBlock>
                  <referenceBlock name="register-link" remove="true"/>





                  share|improve this answer













                  Add this code in default.xml



                   <referenceBlock name="header.links">
                  <block class="MagentoCustomerBlockAccountRegisterLink" name="register-link-new" after="-">
                  <arguments>
                  <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
                  </arguments>
                  </block>
                  <block class="VendorModuleBlockToplink" name="add.subscriptionplan.top" ifconfig="Vendor_Module/general/enable" after="-" />
                  </referenceBlock>
                  <referenceBlock name="register-link" remove="true"/>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 16 hours ago









                  Birjitsinh ZalaBirjitsinh Zala

                  559115




                  559115























                      1














                      @Chirag Patel code almost right.



                      Only have to add below code after



                      <move element="some_link" destination="header.links" before="-"/>



                      or



                      <move element="some_link" destination="header.links" before="header"/>


                      after </referenceBlock> tab on default.xml.



                      It will move your link at first






                      share|improve this answer
























                      • Thanks @Amit Bera for make good answer to perfect answer. +1 for this. :)

                        – Chirag Patel
                        15 hours ago
















                      1














                      @Chirag Patel code almost right.



                      Only have to add below code after



                      <move element="some_link" destination="header.links" before="-"/>



                      or



                      <move element="some_link" destination="header.links" before="header"/>


                      after </referenceBlock> tab on default.xml.



                      It will move your link at first






                      share|improve this answer
























                      • Thanks @Amit Bera for make good answer to perfect answer. +1 for this. :)

                        – Chirag Patel
                        15 hours ago














                      1












                      1








                      1







                      @Chirag Patel code almost right.



                      Only have to add below code after



                      <move element="some_link" destination="header.links" before="-"/>



                      or



                      <move element="some_link" destination="header.links" before="header"/>


                      after </referenceBlock> tab on default.xml.



                      It will move your link at first






                      share|improve this answer













                      @Chirag Patel code almost right.



                      Only have to add below code after



                      <move element="some_link" destination="header.links" before="-"/>



                      or



                      <move element="some_link" destination="header.links" before="header"/>


                      after </referenceBlock> tab on default.xml.



                      It will move your link at first







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 15 hours ago









                      Amit BeraAmit Bera

                      59.2k1575177




                      59.2k1575177













                      • Thanks @Amit Bera for make good answer to perfect answer. +1 for this. :)

                        – Chirag Patel
                        15 hours ago



















                      • Thanks @Amit Bera for make good answer to perfect answer. +1 for this. :)

                        – Chirag Patel
                        15 hours ago

















                      Thanks @Amit Bera for make good answer to perfect answer. +1 for this. :)

                      – Chirag Patel
                      15 hours ago





                      Thanks @Amit Bera for make good answer to perfect answer. +1 for this. :)

                      – Chirag Patel
                      15 hours ago


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266268%2fhow-can-add-link-in-header-link-before-the-welcome-message-in-magento-2%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      數位音樂下載

                      When can things happen in Etherscan, such as the picture below?

                      格利澤436b