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
Manish Gaur
3672 gold badges6 silver badges15 bronze badges
1 Answer 1
Follow the below steps
Extend your default_head_blocks.xml at
app\design\frontend\Packagename\Themename\Magento_Theme\layout\default_head_blocks.xmland 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>Add the CSS file at this path:
app\design\frontend\Packagename\Themename\web\css\custom.cssAnd do a static deploy
php -dmemory_limit=5G bin/magento setup:static-content:deploy
7ochem
7,61516 gold badges54 silver badges82 bronze badges
-
there is no layout folder in \app\design\frontend\Packagename\Themename\Magento_Theme\Manish Gaur– Manish Gaur2017年08月29日 07:45:58 +00:00Commented Aug 29, 2017 at 7:45
-
you need to createManoj Deswal– Manoj Deswal2017年08月29日 07:51:00 +00:00Commented Aug 29, 2017 at 7:51
-
ok thanks.. its working now. now i can add custom css. Thanks you so much Shyam and Manoj.Manish Gaur– Manish Gaur2017年08月29日 08:31:38 +00:00Commented Aug 29, 2017 at 8:31
-
I am on magento 2.2.3 and it is not working for me...James Tsai– James Tsai2018年03月31日 15:02:43 +00:00Commented Mar 31, 2018 at 15:02
default