Any advise how is the best to adjust .css (colors), that it would stay permanently?

After editorials in .css and flushed cached all changes in .css disappeared. Any advise how I could keep them permanently?

  • 1
    Were you editing css files in install_root/pub/static?
    – Pmclain
    Commented Jul 5, 2017 at 21:03
  • yes, in there. pub/static/frontend/Magento/luma/de_DE/css
    – Ausra
    Commented Jul 6, 2017 at 12:14

2 Answers 2


To make your CSS changes stay permanently in Magento 2

Follow below steps for adding custom css and changing existing CSS.

Option 1) Extend the module whom CSS you want to change, for example cart page css

so after extending Magento_Checkout module you can change that in _cart.less under below extended path


Option 2) Extend _extend.less under below path , here you can also write your custom CSS/LESS or can overwrite existing.


Option 3) Adding Via XML , for example adding bootstrap CSS/JS or your custom stylesheet

Add below code in your default_head_blocks.xml under your extended theme


<css src="css/bootstrap.css" />
<css src="css/custom.css" />
<script src="js/jquery-1.11.3.min.js"></script>

kepp all file under below path to work flawless


To make less changes work efficiently don't forget to run upgrade/deploy/cache commands

I hope this will help you out


Magento2 dont writes CSS directly on css files.

Magento CSS preprocessing is different totally different process. Its using LESS for Css processing

In css files, you cannot write css code directly:

  1. For any changes at css files, you should write code in respective less files


2.Magento2 less processor, is take all less from theme ,then genereta css and less at MagentoDir/var/view_preprocessed/source/[Area=frontend/adminhtml]/[Vendorname]/[ThemeName]/en_US/css

After that:

  1. copy those css to MagentoDir/pub/static/[Area=frontend/adminhtml] /[Vendorname]/[ThemeName]/

So when you have cache then files at MagentoDir/var/view_preprocessed replaced .

So if you anything changes at pub/static and refresh the it automatically remove from those as those folder files are regenerate whenever run flush cache.

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.