Magento 2 – Removing Welcome Message Using XML

headerlayoutmagento2xml

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?

Best Answer

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"/>