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?

2

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>
  • Do I have to create cms_index_index.xml or I cam past the same in default.xml? – iamkdev Oct 14 '16 at 13:04
  • you have to create cms_index_index.xml file – Rakesh Jesadiya Oct 14 '16 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.