1

I want to add one css file to the home page but not to the contact us page. I added like this on default.xml but it load on all pages.

<head>
  <css src="css/app.css"/>
</head>

How to do it?

0

1 Answer 1

1

you have to add inside cms_index_index.xml file file to display only in homepage

<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/app.css"/>
       <link src="js/custom.js"/>
    </head>
    <body>
    </body>
</page>
2
  • Do I have to create cms_index_index.xml or I cam past the same in default.xml?
    – user44765
    Commented Oct 14, 2016 at 13:04
  • you have to create cms_index_index.xml file Commented Oct 14, 2016 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.