1

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

1 Answer 1

0

Looks like Layout Update XML is no more useful in Magento 2.4 so the alternate solutions is just add the new file in child theme.

app/design/frontend/Vendor/mytheme/Magento_Cms/layout/cms_page_view_selectable_cmsurl_LandingPG.xml

<?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>
    <css src="css/landingpg.css"/>
</head>

Where, cmsurl is the url of CMS Page & LandingPG can be anything that will come visible under the Design -> Custom 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.