I am trying to create a theme with Magento Blank as parent in Magento 2 but I can't figure it out how to change the header with a custom one.

I first remove header.container from magento blank and create my container but it is created inside page-wrapper between main-content and footer and I can't make it go before main-content.

This is my layout.xml:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="register-link" remove="true" />
        <referenceBlock name="authorization-link" remove="true" />
        <referenceBlock name="wish-list-link" remove="true" />
        <referenceBlock name="my-account-link" remove="true" />
        <referenceBlock name="top.links" remove="true" />
        <referenceBlock name="header.panel.wrapper" remove="true" />
        <referenceBlock name="header.container" remove="true" />

        <referenceContainer name="page.wrapper">
            <container name="custom.header" htmlClass="headerSection" htmlTag="div">
                <block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml">



And this is how it looks the HTML:

enter image description here

1 Answer 1


Well this is because your before attribute is not set.

To fix that, replace:

<container name="custom.header" htmlClass="headerSection" htmlTag="div">


<container name="custom.header" htmlClass="headerSection" htmlTag="div" before="main.content">
  • 1
    -.- I was trying with the before but in the block and not the container. Thanks!
    – codiaf
    Commented May 4, 2016 at 17:18

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.