0

I added css on my website. One is bootstrap and one is a custom css. I addedd it on my Magento_Theme folder (inside layout/default_head_block.xml)

<css src="css/bootstrap/css/bootstrap.css" order="100" />
<css src="css/reflexmania2-custom.css" order="100" />     

suddenly there was a problem on these css. They are not loaded in the frontend css inside the HEAD tag.

i tried cleaning cache, generated folders, view_preprocessed and then running

setup:upgrade
setup:di:compile
setup:static-content:deploy 

but nothing. they are not loaded.

they are compiled because i can see inside my pub/static folder.

i'm getting crazy. How can i solve this problem?

Thanks for help

EDIT: 1 --> added xml 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 name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>

 <css src="css/bootstrap/css/bootstrap.css" order="100" />
 <css src="https://use.fontawesome.com/releases/v5.4.1/css/all.css"  src_type="url" order="100" />
 <css src="css/reflexmania2-custom.css" order="100" />

</head>
</page>

Some notes: inside my Pub/static folder i have got all my css and layout.they are not working nor called from my theme. If i restore a previous version of my theme is the same. I think that there is some problem on pub static or some permission but i cannot understand where.

!(https://i.sstatic.net/4TDjf.png)

8
  • Can you specify your CSS file path? Also please make sure that layout file name should be default_head_blocks.xml Commented Jan 7, 2019 at 16:10
  • yes, i put css inside Theme/Module/web/css folder. I see that there is some xml errors because the theme is not loaded properly and my changes to the XML are not loaded properly. How can i debug the error?
    – Francesco
    Commented Jan 7, 2019 at 16:19
  • Is your XML file name with blocks ? In your question, you mentioned block Commented Jan 7, 2019 at 16:20
  • yes. the name is correct
    – Francesco
    Commented Jan 7, 2019 at 16:27
  • Can you add the code of your entire XML file? Commented Jan 7, 2019 at 16:33

2 Answers 2

0

First, there is no order property, with this you should have an Exception (property not valid).

To add css :

app/design/frontend/{Vendor}/{themename}/Magento_Theme/layout/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>
        <css src="css/bootstrap/css/bootstrap.css" />
        <css src="css/reflexmania2-custom.css" />
    </head>
</page>

app/design/frontend/{Vendor}/{themename}/web/css/bootstrap.css

/*Some content*/

app/design/frontend/{Vendor}/{themename}/web/css/reflexmania2-custom.css

/*Some content*/

Then execute : php bin/magento setup:static-content:deploy -f

2
  • no. nothing solved. i tried switching databases with one website that it's working and this solved the problem. i think there is something inside the database or inside the pub static folder that it's not loaded properlu
    – Francesco
    Commented Jan 8, 2019 at 8:40
  • maybe there is some problem on the pub static folder or some htaccess...
    – Francesco
    Commented Jan 8, 2019 at 9:38
0

solved this problem. I don't know how but something changed my theme from phisical to virtual on my db table 'themes'. Just changed the value from 0 -> 1 and all works without problems.

this looks like a problem of magento2 and virtual themes is not completely developed: Magento 2 - Theme Type 0:physical, 1:virtual, 2:staging. When to use?

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.