2

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!

UPDATE

per suggestions below, I changed the directory structure.... still does not work, this is the new directory structure

enter image description here

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>
4

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 Jan 27 '16 at 15:10
  • You can see theme luma inside folder \vendor\magento\theme-frontend-luma as example. Make sure files like theme.xml, registration.php in root of theme dir have right config – mrtuvn Jan 27 '16 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 Jan 28 '16 at 18:38
  • 1
    You should disable cache. Enable developer mode by uncomment inside .htaccess in root magento dir. Clear some folders var\cache var\generation pub\static\frontend\Magento var\view_preprocessed\css\frontend\Magento var\view_preprocessed\source\frontend\Magento. Finally run command php bin/magento setup:static-content:deploy. Make sure your theme loaded inside backend, find it in left menu Content > Themes – mrtuvn Jan 28 '16 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 Jan 28 '16 at 19:40
1

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 Jan 28 '16 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 Jan 28 '16 at 14:39
0

Problem is with attempting to inherit from luma.

Inheriting from blank, the custom css and js load properly.

Inheriting from luma, they do not.

source: https://github.com/magento/magento2/issues/2547

0

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.
0

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.

See also: https://github.com/magento/magento2/issues/4330

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.