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– Adad642017年08月08日 22:26:34 +00:00Commented Aug 8, 2017 at 22:26
-
In pub/static folder find where is paymentfont.min.css file?Sweety Masmiya– Sweety Masmiya2020年01月03日 05:01:48 +00:00Commented Jan 3, 2020 at 5:01
2 Answers 2
<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/csscdx– cdx2016年07月06日 15:11:19 +00:00Commented Jul 6, 2016 at 15:11
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.