7

I've started to work on Magento 2 and get my head around it, I'm really familiar with Magento 1 and removing the welcome message was no big deal.

However all I've found the location of the welcome message in the header, but can't seem to find the XML to remove the block from the header.

Is it possible to remove the welcome message with the XML or do I need to simply comment out the switch inside of the header.phtml file?

1
  • 1
    The one that says Default welcome msg!, and displays in the top right, correct? Commented Dec 31, 2016 at 17:46

2 Answers 2

16

The welcome message is in html/header.phtml and the block is referenced from this XML file: /vendor/magento/module-theme/view/frontend/layout/default.xml. The template is referenced by the $_template property within the \Magento\Theme\Block\Html\Header block.

If you want to maintain some of the customer welcome functionality, you will need to override the template. However, if you want to remove that, you have two options. First, you can keep the header intact and just hide the welcome message with XML like this (ThemeNamespace/ThemeDirectory/view/frontend/layout/default.xml):

<referenceBlock name="header">
    <arguments>
        <argument name="show_part" xsi:type="string">other</argument>
    </arguments>
</referenceBlock>

If you want to completely remove the header.phtml file altogether, the following XML in the same place should do that:

<referenceBlock name="header" remove="true"/>
9
  • Cool thats great. Makes sense now :)
    – andy jones
    Commented Jan 1, 2017 at 13:38
  • What if I want to move it to different place
    – Omer
    Commented Jun 5, 2017 at 10:05
  • @Omer, I would try <move />: devdocs.magento.com/guides/v2.1/frontend-dev-guide/layouts/… Commented Jun 6, 2017 at 12:54
  • Hi there! @bassplayer7, I'm really happy I came across this as this explanation is the closest I've gotten to my own question. Would you be able to help me out? I've located these files you've talked above above, however I'm really only looking to move JUST the welcome message. I'd like to have it full width above the header. So ideally I'd like to do something like: <move element="welcome.message" destination="header.panel" before="-"/> but alas I do not know the hook for the welcome message. Are you able to provide any help on this?
    – kia4567
    Commented Oct 22, 2018 at 22:48
  • @kia4567, the welcome message is in the header template. My suggestion would be to hide it as described above and then add another block in the desired location with the same block class but different name. Commented Oct 23, 2018 at 18:57
3

In your theme 'your_theme/Magento_theme/layout/default.xml' add below code

 <referenceBlock name="header.panel.wrapper" remove="true"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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