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?

sv3n
11.7k7 gold badges44 silver badges75 bronze badges
asked Jul 6, 2016 at 14:35
2
  • 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. Commented Aug 8, 2017 at 22:26
  • In pub/static folder find where is paymentfont.min.css file? Commented Jan 3, 2020 at 5:01

2 Answers 2

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.

answered Jul 6, 2016 at 14:53
1
  • The CSS files are in the following folder: app/design/frontend/Customvendor/customtheme/web/css Commented Jul 6, 2016 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.
anonymous
3,7624 gold badges26 silver badges67 bronze badges
answered Oct 15, 2017 at 11:07

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.