0

in Magento 2.3.0 I have followed the above solution but still not loading my css, I have search ran all the commands but still nothing. Please any mistake on my implentation below, I am trying to add custom.css to the luma theme.

app/design/frontend/Magento/Luma/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/custom.css"/>
    </head>
</page>

app/design/frontend/Magento/Luma/web/css/custom.css

or

app/design/frontend/Magento/Luma/Magento_Theme/web/css/custom.css

6
  • In your case follow the below answer and update xml with head tags will get you there. peace :) Feb 28, 2019 at 13:43
  • Sorry about that meant to paste the below<?xml version="1.0"?> <!-- /** * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="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="Magento_Theme::css/custom.css" /> </head> </page>
    – Local
    Feb 28, 2019 at 13:59
  • It should not be Magento_Theme it must be as below Feb 28, 2019 at 14:01
  • Did that already but doesnt work still
    – Local
    Feb 28, 2019 at 14:05
  • Magento luma will be vendor folder have you created a theme with the same name so Feb 28, 2019 at 14:12

2 Answers 2

3

Adding CSS in Luma theme is not good practice. Better to create a Custom Theme: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/themes/theme-create.html

And add CSS as below:

1) Adding custom CSS: add a file under app/design/frontend/VenderName_Theme_name/Magento_Theme/frontend/web/css/custom.css and add one more file to call that app/design/frontend/VenderName_Theme_name/Magento_Theme/layout/default.xml

add below content in the default.xml

<?xml version="1.0"?>                                             
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/Module/etc/module.xsd">                                                 
 <head>
  <css src="css/custom.css" />                                   
 </head>                                                         
</page>

Hope it helps!

0

Start adding a default_head_blocks.xml file in the module’s view/frontend/layout folder, For custom CSS for a specific layout, we'll start with default_head_block.xml layout. It will apply to all pages in Magento.

<?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="Magenest_CustomCss::css/css-module.css"/>
</head></page>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.