0

I have this structure :

|-app/design/frontend
 |-Magento
   |-Theme
     |-layout
       |--default.xml
       |--default_head_blocks.xml
     |-Magento_Theme 
       |-templates 
     |-web
       |-css
         |--custom-m.css
       |-js
   |-theme.xml
   |-requirejs-config.js
   |-registration.php

In default.xml :

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="head">
            <block class="Magento\Theme\Block\Html\Head\Script" name="requirejs" before="-">
                <arguments>
                    <!-- RequireJs library enabled -->
                    <argument name="file" xsi:type="string">requirejs/require.js</argument>
                </arguments>
            </block>
            <!-- Special block with necessary config is added on the page -->
            <block class="Magento\RequireJs\Block\Html\Head\Config" name="requirejs-config" after="requirejs"/>
        </referenceBlock>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_file" xsi:type="string">images/logo.png</argument>
            </arguments>
        </referenceBlock>
        <remove name="report.bugs"/>
    </body>
</page>

And in 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>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <css src="mage/calendar.css"/>
        <script src="requirejs/require.js"/>
        <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" src_type="url"/>
        <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" src_type="url"/>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous" src_type="url"/>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous" src_type="url"/>
        <css src="Magento_Theme::css/custom-m.css"/>
    </head>
    <body>
        <referenceContainer name="after.body.start">
            <block class="Magento\Framework\View\Element\Template" name="head.polyfill" as="polyfill" template="Magento_Theme::js/polyfill.phtml" before="-"/>
            <block class="Magento\Framework\View\Element\Js\Components" name="head.components" as="components" template="Magento_Theme::js/components.phtml" before="-"/>
        </referenceContainer>
    </body>
</page>

But my custom-m.css in not detected. Any ideas ?

EDIT :

In fact, the problem is from my default_head_blocks.xml. Bootstrap is not charging inside this (i added cdn in phtml file, but i forgot), so i'll try to figure out the problem

  • Try placing your "layout" folder inside the "Magento_Theme" directory – Haritha Jun 12 '18 at 12:06
  • Not working with this :/ – Morgan Tartreau Jun 12 '18 at 12:12
0

Try placing the layout in the following format,

 |-app/design/frontend
  |-Magento
    |-Theme
      |-Magento_Theme 
        |-layout
          |--default.xml
          |--default_head_blocks.xml
        |-templates 
      |-web
        |-css
          |--custom-m.css
        |-js
      |-theme.xml
      |-requirejs-config.js
      |-registration.php

After placing, Clear cache

try changing <css src="Magento_Theme::css/custom-m.css"/> to <css src="css/custom-m.css"/> in default_head_blocks.xml

  • Not changing, already tried – Morgan Tartreau Jun 12 '18 at 12:26
  • Have you tried changing <css src="Magento_Theme::css/custom-m.css"/> to <css src="css/custom-m.css"/> in default_head_blocks.xml – Haritha Jun 12 '18 at 12:34
  • Yes, still not working – Morgan Tartreau Jun 12 '18 at 12:42
  • @MorganTartreau Please check active theme from backend ! – lalit mohan Jun 12 '18 at 14:25
  • It's working in backend – Morgan Tartreau Jun 12 '18 at 15:19
0

You can try following ways

 <head>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <css src="mage/calendar.css"/>
        <script src="requirejs/require.js"/>
        <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" src_type="url"/>
        <css src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" src_type="url"/>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous" src_type="url"/>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js" integrity="sha384-u/bQvRA/1bobcXlcEYpsEdFVK/vJs3+T+nXLsBYJthmdBuavHvAW6UsmqO2Gd/F9" crossorigin="anonymous" src_type="url"/>
        <css src="css/custom-m.css"/>
    </head>

css/custom-m.css Must be under app/design/frontend/package/themename/web/css directory.

Now run code into cli

php bin/magento setup:static-content:deploy en_US -f  //production mode

Then make clear cache & permission of generating folders

php bin/magento cache:flush

chmod 777 -R var/ pub/static generated/

Let me know if fixed.

  • Not changing (i'm in developer mode) – Morgan Tartreau Jun 12 '18 at 12:05
  • open browser console. check any 404 error – MR.R DNATH Jun 12 '18 at 12:13
  • also check store code..... IF you are using different store Need to run php bin/magento setup:static-content:deploy en_US ar_SA -f like that. – MR.R DNATH Jun 12 '18 at 12:15
  • No error 404, this css file not detected at all. I'm only using 1 store – Morgan Tartreau Jun 12 '18 at 12:17
  • 1
    default.xml use for all pages but default_head_blocks.xml use for head block in m2 – MR.R DNATH Jun 12 '18 at 15:38

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.