Magento – Magento 2 child theme: CSS files not included

csscustommagento2theme

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?

Best Answer

<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.

Related Topic