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
    Mar 18 at 6:53
















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
    Mar 18 at 6:53














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 Mar 18 at 6:52









Amit Bera

59.5k1676177




59.5k1676177










asked Mar 18 at 6:42









HaFiz UmerHaFiz Umer

3949




3949








  • 2





    I donot think this is a duplicated answer

    – Amit Bera
    Mar 18 at 6:53














  • 2





    I donot think this is a duplicated answer

    – Amit Bera
    Mar 18 at 6:53








2




2





I donot think this is a duplicated answer

– Amit Bera
Mar 18 at 6:53





I donot think this is a duplicated answer

– Amit Bera
Mar 18 at 6:53










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
    Mar 18 at 6:55











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

    – Yogesh
    Mar 18 at 7:09



















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
        Mar 18 at 7:22











      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
        Mar 18 at 6:55











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

        – Yogesh
        Mar 18 at 7:09
















      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
        Mar 18 at 6:55











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

        – Yogesh
        Mar 18 at 7:09














      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 Mar 18 at 7:08

























      answered Mar 18 at 6:46









      YogeshYogesh

      332211




      332211








      • 2





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

        – Amit Bera
        Mar 18 at 6:55











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

        – Yogesh
        Mar 18 at 7:09














      • 2





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

        – Amit Bera
        Mar 18 at 6:55











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

        – Yogesh
        Mar 18 at 7:09








      2




      2





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

      – Amit Bera
      Mar 18 at 6:55





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

      – Amit Bera
      Mar 18 at 6:55













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

      – Yogesh
      Mar 18 at 7:09





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

      – Yogesh
      Mar 18 at 7:09













      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 Mar 18 at 6:59









          Chirag PatelChirag Patel

          2,368423




          2,368423























              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 Mar 18 at 6:52









                  Birjitsinh ZalaBirjitsinh Zala

                  564115




                  564115























                      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
                        Mar 18 at 7:22
















                      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
                        Mar 18 at 7:22














                      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 Mar 18 at 7:16









                      Amit BeraAmit Bera

                      59.5k1676177




                      59.5k1676177













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

                        – Chirag Patel
                        Mar 18 at 7:22



















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

                        – Chirag Patel
                        Mar 18 at 7:22

















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

                      – Chirag Patel
                      Mar 18 at 7:22





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

                      – Chirag Patel
                      Mar 18 at 7:22


















                      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

                      How to change which sound is reproduced for terminal bell?

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents