I had created a couple of cms static blocks in Magento 2 luma theme and added inline styles and javascript inside the blocks. Now I'm confused that where I could place those CSS and js files inside the directory and how to call it.

1 Answer 1


For styling your CMS Blocks add custom CSS, js or adding bootstrap, call files in default_head_blocks.xml


<css src="css/bootstrap.css" />
<script src="js/bootstrap.js"></script>

Place both files under /app/design/frontend/yourvendor/yourtheme/web/css or js

you can call all required CSS and js files in same way

  • I couldnt see any files inside app/design/frontend.
    – ren
    Jun 27, 2017 at 7:11
  • you should have extended your theme Jun 27, 2017 at 7:18
  • I tried to add the custom css file inside vendor\magento\theme-frontend-luma\Magento_Theme\web\css ,And called css files inside vendor\magento\theme-frontend-luma\Magento_Theme\layout\default_head_blocks.xml.But css is not lodaing.
    – ren
    Jun 27, 2017 at 9:29
  • I found that ,we had to paste the css files inside pub/static frontend/Magento/luma/css and this worked for me.
    – ren
    Jun 27, 2017 at 9:48
  • Bad idea @ren - That directory will be deleted when you run a static-content deploy and you'll lose your changes.
    – Ben Crook
    Jun 27, 2017 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.