Magento 2.2.4 – Fix Invalid Template File Error

magento2magento2.2.4

I am a newbie to Magento and I am trying to create a child theme with the parent as blank.

Now my task is to override the full layout and map bootstrap CSS so I don't want to read the CSS structure of Magento as will I could create responsive layouts easily. In simple words, I can have better control over the template.

I was able to override default.xml file in my theme. Now if I map the .phtml file from the templates folder, I am getting the error as

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Magento_Theme::html/navbar.phtml' in module: '' block's name: 'header.container_schedule_block0'

default.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. 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">
    <body>
     <referenceContainer name="header.container">
           <block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/navbar.phtml"></block>
        </referenceContainer> 
    </body>
</page>

navbar.phtml

<?php

echo "Hello world" ?>

My folder structure is as attached.

enter image description here

I am sure, I didn't understand the documentation properly. So please do not refer the documentation link. Please point the mistake and how to clear the error.

Magento Version 2.2.4

Thanks.

Best Answer

<block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/navbar.phtml"></block>

According to your folder structure, it should be like below

<block class="Magento\Framework\View\Element\Template" template="Magento_Theme::navbar.phtml"></block>