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
For styling your CMS Blocks add custom CSS, js or adding bootstrap, call files in default_head_blocks.xml
#app/design/frontend/yourvendor/yourtheme/Magento_Theme/layout/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 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.– renJun 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.– renJun 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. Jun 27, 2017 at 9:49