Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom .css files not loading in browser head added via default_head_blocks.xml in Magento 2.0.4 child theme #4274

Closed
shashankitsoft opened this issue Apr 22, 2016 · 5 comments

Comments

@shashankitsoft
Copy link

Steps to reproduce

  1. Installed Magento 2.0.4 community with sample data on local WAMP server 3.0 on Windows 10 Pro (32-bit). Apache: 2.4.17, PHP: 5.6.15, MySQL: 5.7.9.
  2. Installed, configured and activated a paid theme which is actually a child theme of Magento_blank theme. Working fine. Also, this theme added custom .css files via default_head_blocks.xml and putting file in web/css folder. That's loading in browser properly.
  3. Created a child theme of above theme which in turn a child theme of Magento_blank, activated and running properly (with no customizations).
    I mean the hierarchy of my child theme is Magento_blank --> Paid_Theme --> My_Child_theme
    Then I want to add css styling file in head of my child theme, so added mycustom.css file in app\design\frontend\company\childtheme\web\css\mycustom.css and also created app\design\frontend\company\childtheme\Magento_Theme\layout\default_head_blocks.xml with content
    <page …><head><css src="css/mycustom.css" /></head> </page>
    The process was exactly followed as per the Magento 2 instructions on http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html#layout_markup_css
  4. Cleared var and pub/static folders, but mycustom.css is not included in the when running in browser.
  5. Also tried with command php bin/magento setup:static-content:deploy, and mycustom.css file then available in pub/static but still not included in browser html .
  6. Also, tried with command php bin/magento indexer:reindex and php bin/magento setup:upgrade, still no success.

Expected result

As my theme is a child theme of a parent theme which is a child theme of Magento_blank and created with the rules as defined by magento, mycustom.css should have included in while running in browser.
Although, I have checked, that parent theme is also using the same way to load their custom.css by putting in web/css and adding in layout\default_head_blocks.xml. Their custom.css is loading properly in browser.
Why not my child theme unable to add mycustom.css the same way then?

Actual result

mycustom.css of my child theme not loaded anyway in browser even all above steps tried. I am unable to customize y site therefore.

I suspect this is a serious bug in magento 2, which is unable to load custom css files via layout\default_head_blocks.xml in child themes. Searched for solutions alot on internet, tried everything but nothing worked. Also, no where is mentioned if Magento 2 needs some parameters to set in a theme to allow it act as a parent theme and allow custom css addtions in its child theme.

@odubovyk
Copy link
Contributor

Shashankitsoft, thank you for reporting the very detailed issue. Your steps to reproduce (installing two themes as described: Magento_blank -> Paid_Theme -> My_Child_theme ) are correct. We went through the steps, but we cannot reproduce the issue. Please try to go through the steps again more carefully, perhaps you miss something out of focus. And give us your feedback.

@shashankitsoft
Copy link
Author

Thank you for the response. From the time I posted this issue, I myself digged into it much to find the reason. And found out that there is no issue if the child theme and its parent paid theme (child of magento blank) are under the same vendor folder. But if the folder name is different for child and parent then this issue occurs, that no .xml files of childtheme processed while rendering in browser.

That's why I posted a second issue #4330 more detailing the new steps for reproducing this issue. Please refer to newer one here: #4330

Thanks.

@maksek
Copy link
Contributor

maksek commented May 9, 2016

@shashankitsoft should we close the issue, since it is new one created?

@shashankitsoft
Copy link
Author

shashankitsoft commented May 9, 2016

@maksek yep sure. It can be closed. The cause/solution found by myself which is mentioned in #4330

@shoshweb
Copy link

Hi,
I am having this same issue and just can't seem to resolve it.
I'm pulling my hair out.
I'm not even sure how to ask for help now, as I've tried everything mentioned in this post and the posts linked to this post.
So.. any new ideas?
I really want to be able to use a custom.css.
Thanks so much,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants