I have merge and minify CSS enabled and I would like to know if is there a way to exclude a specific CSS file from the final merged file, but only for the homepage?

I know how to remove a CSS file from the header via XML layout...

<remove src="css/styles-m.css" />

But can you remove/exclude this from the final compiled CSS file, just for the homepage?


  • for my knowledge is no way
    – xanka
    Commented May 30, 2019 at 9:53

1 Answer 1


If it helps anybody (using Magento 2.1.4), I managed to do this by first adding my CSS file to the exclude list in my view.xml

    <item type="file">Module_Name::css/stylesheet.css</item>

I then created a new cms_index_index.xml and put it in


Then added this to remove the file from the homepage...

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <remove src="Module_Name::css/stylesheet.css"/>

I thought this would mean that the file is then not minified and merged for all other pages, but no... it still appears in my merged and minified master CSS file for all other pages (except the homepage)

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.