Posted on

Add Css in Custom layout xml

I created a custom layout to display only parent categories not subcategories. But I need custom css for that layout. I create custom_layout in Magento_Theme/page_layout folder and defined in layouts.xml. Which works fine. But how I add css to that custom layout.
My custom layout is

<page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/Layout/etc/page_configuration.xsd”>
<update handle=”1column”/>
<referenceContainer name=”page.wrapper”>
<referenceBlock name=”breadcrumbs” remove=”true” />
<referenceBlock name=”page.main.title” remove=”true”/>
<referenceBlock name=”category.description” remove=”true” />
</referenceContainer>

and layouts.xml as

<page_layouts xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:View/PageLayout/etc/layouts.xsd”>
<layout id=”category_level_one”>
<label translate=”true”>Category Level One</label>
</layout>

I need to add css like

<head>
<css src=”css/demo.css” media=”all”/></head>

Which is not working. How to resolve this issue? Thanks in advance.

Leave a Reply

Your email address will not be published.