1

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

asked Aug 29, 2017 at 7:34

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
    
7ochem
7,61516 gold badges54 silver badges82 bronze badges
answered Aug 29, 2017 at 7:41
4
  • 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... Commented Mar 31, 2018 at 15:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.