Magento 2 Error – Understanding and Fixing Common Errors

magento2xml

Tried to install a store locator extension.

When go to the front end producing this error.

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block': This element is not expected. Expected is one of ( title, css, link, meta, script, remove, attribute ).
Line: 708

Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'block': This element is not expected. Expected is one of ( title, css, link, meta, script, remove, attribute ).
Line: 708

0 D:\xampp\htdocs\tork\vendor\magento\framework\Config\Dom.php(115): Magento\Framework\Config\Dom->_initDom('

1D:\xampp\htdocs\tork\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(111): Magento\Framework\Config\Dom->__construct('

How can i fix this issue?.
Magento version 2.2.2

Best Answer

most probably you have in one of your layout files a <block> tag inside the <head> tag.
The <head> tag does not support block child elements.
See the xsd validation schema for head section: https://github.com/magento/magento2/blob/2.2-develop/lib/internal/Magento/Framework/View/Layout/etc/head.xsd#L51

If your next question is, "But I need to add a block to my head section. how do I do that?" then you can check this: Magento 2: Adding Arbitrary HTML to the <head> of Every Page?

Related Topic