1

I have to add new css file for custom theme in magento 2. will anyone please tell me how to add.

1 Answer 1

3

Follow the below steps

  1. Extend your default_head_blocks.xml at app\design\frontend\Packagename\Themename\Magento_Theme\layout\default_head_blocks.xml and place

    <?xml version="1.0"?>
    <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/custom.css" />
        </head>
    </page>
    
  2. Add the CSS file at this path: app\design\frontend\Packagename\Themename\web\css\custom.css

  3. And do a static deploy

    php -dmemory_limit=5G bin/magento setup:static-content:deploy
    
4
  • there is no layout folder in \app\design\frontend\Packagename\Themename\Magento_Theme\ Aug 29, 2017 at 7:45
  • you need to create Aug 29, 2017 at 7:51
  • ok thanks.. its working now. now i can add custom css. Thanks you so much Shyam and Manoj. Aug 29, 2017 at 8:31
  • I am on magento 2.2.3 and it is not working for me...
    – James Tsai
    Mar 31, 2018 at 15:02

Your Answer

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

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