0

I am very new to Magento 2.1.0. but want to install HTML theme (theme integration). When I deploy static content and also in pub folder I can see my .css file under css/source folder.

My theme Structure: <VendorName>/<themeName>/web/css/source.

and after that include my CSS and JS files into the Magento_Theme/layout/default_head_blocks.xml file. Below is my code:

**default_head_blocks.xml**
<?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>
 <meta charset="utf-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <css src="css/source/bootstrap.min.css" />
 <css src="css/source/font-awesome.min.css"/>
 <css src="css/source/slick.css"/>
 <css src="css/source/style.css"/>
 <script src="js/bootstrap.min.js"></script>
 <script src="js/jquery.min.js"></script>
 <script src="js/scripts.js"></script>
 <script src="js/slick.min.js"></script>
 </head>
</page>

I flush the cache, deploy the static content but when I see view source in the browser I am not able to my CSS and js file.

So can anyone help me?

Magento ver:2.1.0

Any kind of help will appreciative.

Mohit Kumar Arora
10.2k7 gold badges29 silver badges57 bronze badges
asked May 25, 2018 at 9:41
3
  • have you select your theme from admin? Commented May 25, 2018 at 9:52
  • Check my answer will help you. Commented May 25, 2018 at 9:58
  • In Magento 2, you can not see your CSS and JS in view source, for that you need to check in browser network and console tab (f12) because all these files running in the background. Better to add some CSS property and check in the frontend. Don't forget to flush the cache and to run static-content command. Commented May 25, 2018 at 10:06

3 Answers 3

0

To apply a theme:

In Admin, go to CONTENT > Design > Configuration.

A Design Configuration page opens. It contains a grid with the available configuration scopes.

For example:

enter image description here

You need to refresh your cache (clear cache)

php bin/magento cache:flush

php bin/magento setup:static-content:deploy

For more information check Magento official document.

answered May 25, 2018 at 9:58
1
  • yes I set the theme from the admin Commented May 25, 2018 at 10:26
0

Put your custom css in below path

/app/design/frontend/VendorName/themeName/web/css/font-awesome.min.css

And call in Magento_Theme/layout/default_head_blocks.xml

<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/font-awesome.min.css"/>
</head>
</page>

You need to run below command

php bin/magento set:up

answered May 25, 2018 at 10:07
4
  • I used your code but I can't see any updates for css and js file. Commented May 25, 2018 at 13:09
  • In which XML have you put above code, please share with me full path with actual XML name Commented May 25, 2018 at 13:51
  • app/design/frontend/Mcardles/default/Magento_Theme/layout/default_head_blocks.xml file. Commented May 26, 2018 at 4:32
  • Please check once in page view source. Your CSS was showing or not. If this project live please share with me URL Commented May 26, 2018 at 7:47
0

kindly run below commands

php bin/magento s:s:d -f
php bin/magento c:f
answered May 25, 2018 at 10:08
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.