UPDATE
Seems that you cannot inherit Luma.... it works properly when inheriting from blank.
github magento source says luma wasn't meant to be inherited.
Challenge is, I really like luma, but need to customize some stuff... so is there a way to do this?
Original Question:
new to Magento 2, followed the directions to make my own theme, a child of luma theme.
now, I cannot figure out why my default head blocks modification is not working.
I have put developer mode on, cleared cache, and it's not loading my custom css or the external font awesome I tried to link to, this is my code inside 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>
<!--Custom Styles-->
<css src="css/cvpstyle.css" />
<!--Before-After Script-->
<link src="js/jquery.twentytwenty.js"/>
<link src="js/jquery.event.move.js"/>
<!--Font Awesome-->
<css src="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" src_type="url" />
</head>
</page>
and my folder structure: my folder structure
have I structured something wrong? I cannot figure out why this won't work. Thanks in advance for any help!
UPDATEper suggestions below, I changed the directory structure.... still does not work, this is the new directory structure
my actual XML: my actual xml
and here's the folder structure now: folder structure
UPDATE - Jan 29
I have gotten closer to the solution I believe... I tried making another theme, and inherited from blank instead of luma, and it seems to work, I can see my css and js loaded, but there's literally NO styling on the page of course from blank.
what I wish to do is start with luma, and add some of my custom css... here is my current XML, is there something wrong with this?
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
<title>CVPStyle</title>
<parent>Magento/luma</parent>
<media>
<preview_image>media/preview.jpg</preview_image>
</media>
</theme>
-
Did you ever fix this? I'm having the same issue on Magento 2.3.5cz84– cz842020年08月05日 11:29:28 +00:00Commented Aug 5, 2020 at 11:29
5 Answers 5
There's an issue with default_head_blocks.xml if the theme type is set to virtual. Check the type field in the theme table. If it's set to 1, try setting it to 0. Then clear the cache and reload the page. See if that does the trick.
-
You saved my dayLouis Serre– Louis Serre2020年09月23日 13:09:18 +00:00Commented Sep 23, 2020 at 13:09
-
I wasted whole week and I read your solution just before restore the whole freaking server.John Fonseka– John Fonseka2021年08月16日 05:23:57 +00:00Commented Aug 16, 2021 at 5:23
-
1This is still working. Thanks! Impressive this hasn't been fixed yet. Got the issue in 2.4.3puntable– puntable2021年10月15日 08:16:42 +00:00Commented Oct 15, 2021 at 8:16
Have you try put layout inside layout dir
basicly theme folder structure is
<theme>
<etc>
<Vendor_Module>
<layout>
<templates>
<web>
<css>
<js>
Remove cache and pub/static/area/Vendor/theme may helps you fix problem
-
Thank you for the reply, I changed the directory structure and updated my original question above with that info... it still does not work? (pub files cleared, cache flushed, etc)M21– M212016年01月27日 15:10:31 +00:00Commented Jan 27, 2016 at 15:10
-
You can see theme luma inside folder
\vendor\magento\theme-frontend-lumaas example. Make sure files like theme.xml, registration.php in root of theme dir have right configmrtuvn– mrtuvn2016年01月27日 16:55:58 +00:00Commented Jan 27, 2016 at 16:55 -
I tried this, and actually re-made my theme now by copying the luma from where you mentioned.... and I now have: /app/design/frontend/myvendor/mytheme/Magento_Theme/layout/default_head_blocks.xml - but after clearing all cache, etc, it still does not load my custom css or js.M21– M212016年01月28日 18:38:35 +00:00Commented Jan 28, 2016 at 18:38
-
1You should disable cache. Enable developer mode by uncomment inside .htaccess in root magento dir. Clear some folders
var\cachevar\generationpub\static\frontend\Magentovar\view_preprocessed\css\frontend\Magentovar\view_preprocessed\source\frontend\Magento. Finally run commandphp bin/magento setup:static-content:deploy. Make sure your theme loaded inside backend, find it in left menu Content > Themesmrtuvn– mrtuvn2016年01月28日 18:46:43 +00:00Commented Jan 28, 2016 at 18:46 -
ok that helps to know what the deploy feature is for... I did all that, exactly in that order, my theme is loaded, but still no custom js or css... I have it as: app > design > frontend > MyVendor > Mytheme > Magento_Theme > layout > default_head_blocks.xml - still isnt working, I think I need to just try and find the core files and try to force my css in there somehow.M21– M212016年01月28日 19:40:50 +00:00Commented Jan 28, 2016 at 19:40
You have added your layouts/ as a direct child of your theme. While this works for assets in the web/ directory, templates and layouts have to belong to a module.
If you move your layouts/ directory to Magento_Theme/layouts/, your default_head_blocks.xml should take effect.
-
@CVP You have invalid XML. There is no closing
</page>tag.Max Bucknell– Max Bucknell2016年01月28日 06:29:03 +00:00Commented Jan 28, 2016 at 6:29 -
thank you, I do actually... I just didn't paste it here, I missed that line when I pasted into this question, I'll update my original post with my actual xml. So I still have no idea why this thing isn't working :(M21– M212016年01月28日 14:39:24 +00:00Commented Jan 28, 2016 at 14:39
Problem is with attempting to inherit from luma.
Inheriting from blank, the custom css and js load properly.
Inheriting from luma, they do not.
Nothing's working with xampp in windows 7 getting the following error whichever theme I choose as parent of my custom theme
Resource interpreted as Stylesheet but transferred with MIME type text/html: "/pub/static/frontend/My_Custom_Theme/theme/en_US/css/mycustom.css".
(index):17 Resource interpreted as Stylesheet but transferred with MIME type text/html: "/pub/static/frontend/My_Custom_Theme/theme/en_US/mage/calendar.css".
(index):1 Refused to execute script from '/pub/static/frontend/My_Custom_Theme/theme/en_US/requirejs/require.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.