If you want to add the specific CSS only for a CMS page and not for all CMS page :
You can add Layout Update XML update for your CMS page here: admin ->CMS -> Pages -> Design -> XML Layout Update
With the content :
<head>
<css src="Namespace_YourModule::css/yourfile.css"/>
</head>
Then there is a bug in Magento 2, you need to override the default Magento 2 vendor/magento/framework/View/Layout/etc/page_layout.xsd
validation file.
A workaround, not a clean solution, but waiting Magento 2 to allow override xsd files
app/code/Vendor/Module/etc/di.xml
<preference for="Magento\Framework\View\Model\Layout\Update\Validator" type="Vendor\Module\Model\Layout\Update\Validator" />
app/code/Vendor/Module/etc/page_layout.xsd
<?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>
app/code/Vendor/Module/Model/Layout/Update/Validator.php
<?php
namespace Hublot\Setup\Model\Layout\Update;
use Magento\Framework\Config\Dom\UrnResolver;
class Validator extends \Magento\Framework\View\Model\Layout\Update\Validator
{
const LAYOUT_SCHEMA_PAGE_HANDLE = 'page_layout';
const LAYOUT_SCHEMA_MERGED = 'layout_merged';
/**
* @param \Magento\Framework\Config\DomFactory $domConfigFactory
* @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver
*/
public function __construct(
\Magento\Framework\Config\DomFactory $domConfigFactory,
UrnResolver $urnResolver
) {
$this->_domConfigFactory = $domConfigFactory;
$this->_initMessageTemplates();
$this->_xsdSchemas = [
self::LAYOUT_SCHEMA_PAGE_HANDLE => $urnResolver->getRealPath(
'urn:hublot:module:Hublot_Setup:etc/page_layout.xsd'
),
self::LAYOUT_SCHEMA_MERGED => $urnResolver->getRealPath(
'urn:magento:framework:View/Layout/etc/layout_merged.xsd'
),
];
}
}
EDIT :
This error seems to be fixed in Magento 2.1.9 or 2.2.0