3

I want to add some CSS files. So I created a child theme.

In Backend the theme is activated.

theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
   <title>Customtheme</title>
   <parent>Smartwave/porto</parent>
</theme>

Magento_Theme/layout/default_head_blocks.xml

<?xml version="1.0"?>
<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/styles.css" />
        <css src="css/paymentfont.min.css" />
    </head>
</page>

CSS files

  • web/css/styles.css
  • web/css/paymentfont.min.css

I cleared the cache, deployed the static data and also reindexed. The static files were created but not included.

Any ideas?

  • I am having the same problem, and so far am not sure why it is occurring. The layout blocks will only extend or override certain XML files (Smartwave_Porto module layout files) and instantly shows changes but any others I've tried are completely ignored. – Adad64 Aug 8 '17 at 22:26
0
<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, maximum-scale=1.0, user-scalable=no"/>
    <css src="css/styles.css" />

</head>

Add your CSS in yourtheme/web/css path and run Deployed content.

That's it.

  • The CSS files are in the following folder: app/design/frontend/Customvendor/customtheme/web/css – cdx Jul 6 '16 at 15:11
0

I thought this might help as I'm using the same theme. I had couple of issues but finally got my child theme working. Here is my folder structure:

app/design/frontend/vendor/{parent_theme}_child consists of the follow folders:

-Magento_Theme

--layout_default_head_blocks.xml

-media

--preview.png

-registration.php

-theme.xml

-web
--css
---style.css

Here is the debug:

  • If you child theme is enabled in admin, then the registration is working, otherwise double check your registration.php and theme.xml.
  • Make sure style.css in the right folder, some tutorials suggest put style.css in child_theme/css/, this doesn't work for me. It needs to
    be in child_theme/web/css/.
  • Make sure default_header_blocks.xml in the right folder. Nikul's answer missing close </page> tag.
  • Give correct file (644) and folder permission(755) to your child theme.
  • Turn developer mode on, it helps in case of syntax issues.

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.