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

1 Answer 1


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">
            <css src="css/custom.css" />
  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
  • there is no layout folder in \app\design\frontend\Packagename\Themename\Magento_Theme\ Commented Aug 29, 2017 at 7:45
  • you need to create Commented Aug 29, 2017 at 7:51
  • ok thanks.. its working now. now i can add custom css. Thanks you so much Shyam and Manoj. Commented Aug 29, 2017 at 8:31
  • I am on magento 2.2.3 and it is not working for me...
    – James Tsai
    Commented Mar 31, 2018 at 15:02

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.