Skip to content

Adding CSS for specific CMS Page via Layout Update XML – Magento 2.4.x

I want to add the custom css for specific CMS Page, I know we can create a new theme for it but I want to use the Layout Update XML Or by adding it to empty page layout directly.

Currently, if I add the below code and hit save, the changes get disappeared from admin and nothing get changes on frontend.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="head">
        <arguments>
            <argument name="css" xsi:type="string">css/landingpg.css</argument>
        </arguments>
    </referenceBlock>
</body>

How to solve this issue