I am going through hard times. After the latest updates, there is no more the Layout Update XML field in the admin panel (Magento 2.3.4). I needed to create a custom layout for some types of cms pages, so I thought of creating one by adding to my child theme:



<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
           <css src="css/csspagine.css"/>
    <referenceContainer name="sidebar.additional"> 
        <block class="Magento\Cms\Block\Block" name="exampleblock"> 
                <argument name="block_id" xsi:type="string">exampleblock</argument> 

and under /app/design/frontend/Vendor/Theme/Magento_Theme/page_layout/layouts.xml

    <layout id="examplepage">
        <label translate="true">Page Example</label>

finally I added the css file csspagine.css


The pages are correctly set in the Magento backend, but the CSS is not loaded. I can't find a solution. Can you help me?

It is important for me that this Css is loaded only on this group of pages and not on the whole site.

thank you all

1 Answer 1


This is easily way for add css for group cms pages Try this :-

Please follow below steps to add css and js to specific cms page using custom module.

  1. Create custom module using below step




<?xml version="1.0" encoding="UTF-8"?>
  <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Mage_Mohit" setup_version="1.0.0"/>

app/code/Mage/Mohit/view/frontend/web/css/custom.css.Then add your css code into custom.css file

And goto your admin panel and open you want to add css page.

  1. GOTO ADMIN -> Content -> Pages -> Edit page -> Design -> Layout Update XML and add below code for particulate page.
   <css src="Mage_Mohit::css/custom.css"/>

For the other cms page create specific css file and add app/code/Mage/Mohit/view/frontend/web/css/ and add that css file into other cms page same as step2 via just changing css file name.

And add more css file this path app/code/Mage/Mohit/view/frontend/web/css and call this type

       <css src="Mage_Mohit::css/more.css"/>

Hope help you

Thanks ...

  • hello @Mohit thank you for the quick reply! Unfortunately in magento 2.3.4, the possibility of being able to insert xml updates has been eliminated under Layout Update XML. So even creating this module, you can't insert: <Head>         <css src="Mage_Mohit::css/more.css"/>      </ Head>
    – Donato P
    Apr 26, 2020 at 15:28
  • Hello @DonatoP check this link and create the .xml file this path app/design/frontend/<Vendor>/<Theme>/Magento_Theme/layout/ and check this link olegnax.com/documentation/magento-2/… . And helpful answer so accept and upvote.So use other community ... Thanks... Apr 26, 2020 at 22:51
  • @MohitPatel you are not looking at 2.3.4 in the 2.3.4 they have removed the option for Layout Update XML. So, unfortunately, the method you provided only work till 2.3.3 Apr 27, 2020 at 13:48
  • Hello @Mohit The solution of adding the css to the page and renaming the xml like this "cms_page_view_id_[cms_page_url].xml" file, works. Unfortunately in doing so, I would have to create many xml pages, one for each store view and every time I would add a page, also in the future I would have to create an xml page just to load a portion of css code that I would not like to show on the other pages of the site. It seems like a very cumbersome thing. I still haven't been able to find a solution for this, It's frustrating. Thanks anyway for replying to me! ;)
    – Donato P
    Apr 27, 2020 at 21:26
  • I think it was a mistake,sorry
    – Donato P
    Apr 28, 2020 at 7:02

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.