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

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

1 Answer 1

0

Add css file as

web/css/mycss.css

instead of

Magento_Theme/web/css/mycss.css

Then deploy the content.

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

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.