0

I have created a child theme of parent theme, and declared default_head_blocks.xml at

<child_theme_dir>/Magento_Theme/layout folder with following content:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/Module/etc/module.xsd">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
        <css src="css/custom.css" media="all"/>
        <css src="css/custom_responsive.css" media="all"/> 
    </head>
</page>

and created these 2 css files in directory:

<child_theme_dir>/web/css

and put my custom styles in those files, deleted all static content form pub folder, deployed static content, cleared all caches but still when I check on front end, the custom.css is not included in output, not sure what I am doing wrong while this seems to be standard process as given here ( https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/css-topics/css-themes.html ) and I did it many times before too.

TIA

---- Added theme.xml & registration.php ---

Though personally I think they have no relation with my problem, still sharing the same, I have personally verified by making changes in other files in my child theme and the changes are getting applied

<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Egon gemsone</title>
    <parent>Mgs/claue</parent>
    <media>
        <preview_image>media/preview.jpg</preview_image>
    </media>
</theme>

registration.php file

<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/Egon/gemsone',
    __DIR__
);
6
  • did you apply your child theme from admin panel? if not goto content->configuration->edit theme and apply your child theme from dropdown. Jan 12 at 8:20
  • yes I did it, initially it was for Store view only, but later on I even tried applying it to website and globally also. Jan 12 at 9:38
  • run s:di:compile or kindly share your theme.xml and registration.php from your theme. Jan 12 at 9:53
  • I already ran all commands like s:upgrade, s:di:compile , s:static-content:deploy , cleared all caches, still as per your message I edited the question and placed theme.xml & registration.php file Jan 12 at 10:52
  • try to remove media tag from your css source tag and then try run all comands like this <css src="css/custom.css"/> Jan 12 at 11:55
0

you have an issue with your default_head_blocks.xml do like this :

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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/custom.css" /> 
    </head>
</page>
11
  • Already tried that before posting question, as tried again but it didn't work :( Jan 13 at 11:43
  • same thing working for me, i dont know whats wrong with your scenario, let me sent you a complete extended theme so you can try this. Jan 13 at 19:50
  • and where do you place your child theme kindly share path. Jan 13 at 19:58
  • download extended theme from here drive.google.com/file/d/179WawRqPQ7nmuH7qc8zedZADp6IiGU2Z/view Jan 13 at 20:16
  • Sorry for responding late, was not available, thanks for all your efforts, I used your files as it is and ran all magento commands still no luck, not sure what's wrong with my environment, as I have done this many times before this is first time I am facing such issue Jan 18 at 11:43

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.