I am trying go create a custom Magento 2 theme. Within this theme I want to add a custom block to the default header.container
. This is what I have so far:
app/design/frontend/Vendor/Theme/templates.header.phtml
<p>Custom Header Content</p>
app/design/frontend/Vendor/Theme/Magento_Theme/layout/default.xml
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="header.container">
<block class="Magento\Framework\View\Element\Template" name="vendor.theme.header" template="Vendor_Theme::header.phtml" />
</referenceContainer>
</body>
</page>
app/design/frontend/Vendor/Theme/registration.php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::THEME,
'frontend/Vendor/Theme',
__DIR__
);
However, in the front end I get the following error message:
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Vendor_Theme::header.phtml' in module: '' block's name: 'vendor.theme.header'
Whenever I search how to create custom blocks within Magento I always come across module implementations, i.e. within app/code/Vendor/Module/….
Since the error message says
in module: ''
I am now beginning to wonder if you aren't really supposed to define blocks within a theme at all?