I want display a phtml file in the header, i created a phtml file and called in the default.xml but it is giving invalid template file block's name, what should be give as a block name


<div class="headercustomlink">MENU</div>


<referenceBlock name="header.container">
        <block class="Magento\Framework\View\Element\Template" name="custom_menu" after="-" template="Company_module::menubtn.phtml"/>

The error means Magento can't find your phtml file.


your phtml file should be in either following location:




Though, I assume your module is actually named "Module" and not "module", so if it is in the right location, verify that is indeed the correct folder name/module name in your layout file. It is case sensitive.

The name of the block can be anything, as long as it doesn't conflict with another block's name.


i am trying to access the template from the theme itself that's why i am getting error, now i created a module and added phtml file in template folder. now its coming good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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