I am trying to move all notification message on the top below header(or any specific location)

I followed this link but this only achieve top for customer page only

Magento 2: Change message location

So that means to place message at the top (below header) i have to each and every xml file of every module?

Is there any shorthand for the same, for all pages.


3 Answers 3


Add this in default.xml in the below path




default.xml will render in all the pages so it's an global declaration.

<?xml version="1.0"?>                                                     
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <move element="messages" destination="header.container" after='-' />

Not tested try it and let me know.

  • Add default.xml in Magento_Theme ?
    – summu
    Mar 11, 2019 at 10:07
  • updated the answer Mar 11, 2019 at 10:09
  • 1
    Thanks worked like a charm
    – summu
    Mar 11, 2019 at 11:11

If you want to move block for every page you should use "Magento_Theme/layout/default.xml" in your theme-directory


first, create layout file in the theme layout

    <reference name="after_body_start">
        <block type="core/template" name="top.messages" template="core/messages/top.phtml" before="-" />

Template: ( app/design/frontend/your_package/your_theme/template/core/messages/top.phtml )

<?php $_messageCollection = $this->getMessagesBlock()->getMessageCollection() 

<?php if ($_messageCollection->count()): ?>
echo $this->getMessagesBlock()->getGroupedHtml();
<?php endif; ?>

please let me know if you have any question

  • I will try your approach also
    – summu
    Mar 11, 2019 at 11:11

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.