2

Magnento default adds following google structured data tags in every page by default.

itemtype

itemscope

itemprop

I want to remove them. I found that you can place below code in your layout xml file.

<attribute name="itemtype" remove="true" />
<attribute name="itemscope" remove="true" />

But this is giving me error for my magento 2.2.6 as below.

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'attribute', attribute 'remove': The attribute 'remove' is not allowed.
Line: 277

Also i tried below.

<attribute name="itemtype" value=""  />
<attribute name="itemscope" value="" />

But that too is also not working. I can remove them using javascript but want to remove by server side only so that it never render to page.

1 Answer 1

0

Exception occur because those attributes are not allowed when using referenceBlock and you should locate them in your code a remove them.

You need to check the available attributes for "referenceBlock" tag in:

/vendor/magento/framework/View/Layout/etc/elements.xsd

the attributes allowed like:

<xs:attribute type="elementNameType" name="name" use="required"/>
<xs:attribute type="xs:string" name="template" use="optional"/>
<xs:attribute type="xs:boolean" name="display" default="true" use="optional"/>
<xs:attribute type="xs:boolean" name="remove" use="optional"/>

This is why an exception is thrown in /vendor/magento/framework/Config/Dom.php (_initDom method).

Reference: https://github.com/magento/magento2/issues/11116

1
  • Thats okay, is there any solution available to get it done ?
    – Yash Shah
    Commented Apr 19, 2019 at 5:55

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.