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

Layout Update XML is no longer useful in Magento 2.4 so the alternate solution is just to add the new file in the 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

Leave a comment

Your email address will not be published. Required fields are marked *