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

asked Feb 28, 2019 at 13:33
6
  • In your case follow the below answer and update xml with head tags will get you there. peace :) Commented 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> Commented Feb 28, 2019 at 13:59
  • It should not be Magento_Theme it must be as below Commented Feb 28, 2019 at 14:01
  • Did that already but doesnt work still Commented Feb 28, 2019 at 14:05
  • Magento luma will be vendor folder have you created a theme with the same name so Commented 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!

answered Feb 28, 2019 at 14:35
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>
answered Sep 29, 2021 at 16:34

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.