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.

  • have you select your theme from admin? – Nikunj Vadariya May 25 '18 at 9:52
  • Check my answer will help you. – Nikunj Vadariya May 25 '18 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. – Nits May 25 '18 at 10:06
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.

  • yes I set the theme from the admin – H_Parekh May 25 '18 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

  • I used your code but I can't see any updates for css and js file. – H_Parekh May 25 '18 at 13:09
  • In which XML have you put above code, please share with me full path with actual XML name – hweb87 May 25 '18 at 13:51
  • app/design/frontend/Mcardles/default/Magento_Theme/layout/default_head_blocks.xml file. – H_Parekh May 26 '18 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 – hweb87 May 26 '18 at 7:47
0

kindly run below commands

php bin/magento s:s:d -f
php bin/magento c:f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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