0

I added custom css in Magento 2 but frontend it shows 404 not found

Magento_Theme/layout/cms_index_index.xml

<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/mycss.css" />
    </head>
    <body>
          <referenceBlock name="wishlist_sidebar" display="false" />
          <referenceBlock name="catalog.compare.sidebar" display="false" />
          <referenceContainer name="columns.top">
            <container label="Top Slideshow Container" name="page.top.slideshow" as="topslideshow" htmlTag="div" htmlClass="slideshow-wrapper" before="-" />
        </referenceContainer>     
      </body>
</page>

I added css in this location Magento_Theme/web/css/mycss.css But frontend it shows 404

  • Did you deploy static content ? – Kishan Patadia May 1 '17 at 19:11
  • Yes i did that and reindex clear cache delete cache folder di:compile command. But no luck – my Test May 1 '17 at 19:12
  • Can you paste whole code here ? – Kishan Patadia May 1 '17 at 19:15
  • this is my full code – my Test May 1 '17 at 19:16
  • What is full directory structure for Magento_Theme/layout/cms_index_index.xml ? – Kishan Patadia May 1 '17 at 19:17
0

Add css file as

web/css/mycss.css

instead of

Magento_Theme/web/css/mycss.css

Then deploy the content.

  • Great. I'm glad it helped you. – Kishan Patadia May 1 '17 at 19:26
  • Hey this css calling only home page how to call all page – my Test May 1 '17 at 19:41
  • use default.xml file instead of cms_index_index.xml – Kishan Patadia May 1 '17 at 19:42

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.