Is it possible to add individual CSS file on each cms page? Upon researching, I can do it by adding code on Layout update XML.

Unfortunately, it isn't working. Here's my code:

  <css src="Namespace_YourModule::css/styles.css"/>

enter image description here

  • Shall i know what is the scenario you need? Commented Jul 4, 2017 at 13:20
  • i want to add css file on a specific cms page, in magento 1 here is the code <reference name="head"> <action method="addCss"> <stylesheet>css/custom.css</stylesheet> </action> </reference> i'm not sure on magento 2 Commented Jul 4, 2017 at 13:23
  • Which magento 2 version you are using currently? Using custom module to set different css for different CMS page is working for me in magento 2.3.3 using Layout Update XML. Commented Jan 12, 2020 at 13:09

2 Answers 2

<?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">
        <css src="css/mycustom.css" after="-" />

If you're on < version 2.1.9 there was apparently a bug to prevent this from working, I've never tried it but you can read about it here - Adding CSS to a CMS page using Layout Update XML

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.