<?xml version="1.0"?>
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
<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" before="main.content">
                <block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/customheader.phtml">



<h1>Custom Header Content here</h1>

It's giving me this error

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Magento_Theme::html/customheader.phtml' in module: '' block's name: 'navigation.sections'

  • Your code seems correct.. just try to clear cache and deploy content if in production mode..
    – Pawan
    Nov 21, 2021 at 13:16
  • I tried both commands "clear cache" and "static content deploy." Nov 21, 2021 at 13:28

1 Answer 1


Try this code :

<referenceBlock name="navigation.sections">
    <action method="setTemplate">
        <argument name="template" xsi:type="string">Magento_Theme::html/customheader.phtml</argument>

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.