Magento – How to add a custom CSS file

cssmagento2

In Magento 2 I have a custom theme and in the layout folder layout>default_head_blocks.xml which contains the css link.

The css file is contained in web>css>customcss.css – but the file is not linking

Best Answer

Just add new file here

app\design\frontend\Vendor\Themename\web\css\_new.less

and import this file in source file given path below

app\design\frontend\Vendor\Themename\web\css\_sources.less

import your file

(if there is not available _source.less file in your theme then go to 'vendor\magento\theme-frontend-blank\web\css\source' folder and copy file in your custom theme)

@import '_new.less';
  1. clear cache
  2. php bin/magento setup:static-content:deploy
Related Topic