Hello all,
I was able before to include custom css in my cms page using the Layout update xml field with this
<head>
<css src="css/home.css"/>
</head>
But since the v2.0.4 I have the following message whenever I try to save my page
"Please correct the XML data and try again. Element 'head': This element is not expected. Expected is one of ( referenceContainer, container, update, move ). Line: 1"
How can I do no to include custom css files in my cms pages?

Also facing the same issue and require to be able to add in custom canonical URLs from the head.
same problem with <body> in layout update xml
Having same problem to add breadcrumto CMS page. This was working in M1.
Hi All!
We already have an internal ticket to solve this problem - MAGETWO-60727
Thanks, any estimation on when a workaround may be released to allow us to implement it immediately?
@devonto Unfortunatly, currently we have no easy and right way to include the css to the specific page. But like a temporary solution you can try to follow the our devdocs documentation - http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/css-topics/css-themes.html OR just to add link for css right to the content description. This is not very good solution, but it works.
I find a workaround for this bug : http://magento.stackexchange.com/questions/126646/magento2-how-to-add-different-custom-css-file-on-specific-cms-pages/166322#166322
The root cause is here : vendor/magento/framework/View/Layout/etc/page_layout.xsd
Need to add :
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>
<xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
Complete file :
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright 漏 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/elements.xsd"/>
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/head.xsd"/>
<xs:include schemaLocation="urn:magento:framework:View/Layout/etc/body.xsd"/>
<xs:complexType name="pageLayoutType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="referenceContainer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="container" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="update" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="move" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="head" type="headType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="body" type="bodyType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="layout" type="pageLayoutType">
<xs:unique name="containerKey">
<xs:selector xpath=".//container"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
</xs:schema>
I do not test the side effect. But it works for me.
How can I use the code to add:
<?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">
<head>
<meta name="robots" content="NOINDEX, NOFOLLOW"/>
<link rel="canonical" href="/sale" />
</head>
</page>
Any news about this issue ? Is it solved in Magento 2.2 ?
@zhiyicai, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9
Can you share the commit which solve this issue ? I am interesting to know how you fix this
I confirm this bug in Magento 2.2.2.
@franckgarnier21 Your workaround works fine!
Hi @zhiyicai. Thank you for your report.
The issue has been fixed in magento/magento2#13817 by @cedricziel in 2.2-develop branch
Related commit(s):
The fix will be available with the upcoming 2.2.4 release.
Hi @zhiyicai. Thank you for your report.
The issue has been fixed in magento/magento2#14205 by @dimonovp in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming 2.3.0 release.
I have 2.3.0, but I don't see this fix. Has it been rolled out to 2.3.0 yet?
@orbitrod 2.3.0 is not released yet. I think you have the 2.2.3 release, which indeed does not contain this fix.
@sanderjongsma Something is wrong with my eyes, yes you are right, I have 2.2.3.
I'm just installing version 2.2.5 and this issue still appears to be there. I double checked and I am positive I am on 2.2.5. Has this possibly regressed since 2.2.4?
same problem with
<body>in layout update xml
@djpaoloc, can you provide an example of how you are using
as a layout instruction to update yourI'm just installing version 2.2.5 and this issue still appears to be there. I double checked and I am positive I am on 2.2.5. Has this possibly regressed since 2.2.4?
@jove4015, did you ever figure out or confirm what was happening in version 2.2.5?
i have a idea we can do this following way
app/design/frontend/
in this xml file put your code
it is work for single category view page
Most helpful comment
I find a workaround for this bug : http://magento.stackexchange.com/questions/126646/magento2-how-to-add-different-custom-css-file-on-specific-cms-pages/166322#166322
The root cause is here : vendor/magento/framework/View/Layout/etc/page_layout.xsd
Need to add :
Complete file :
I do not test the side effect. But it works for me.