1

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

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
    
| improve this answer | |
  • there is no layout folder in \app\design\frontend\Packagename\Themename\Magento_Theme\ – Manish Gaur Aug 29 '17 at 7:45
  • you need to create – Manoj Deswal Aug 29 '17 at 7:51
  • ok thanks.. its working now. now i can add custom css. Thanks you so much Shyam and Manoj. – Manish Gaur Aug 29 '17 at 8:31
  • I am on magento 2.2.3 and it is not working for me... – James Tsai Mar 31 '18 at 15:02

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.