0

I am a new to magento forntend devloper i tried search for this solution i am not getting any solution. This is my custom theme folder structure in Magento 2.2.2 i saved default_header_html.xml file in the following way in layout folder..

app/design/frontend/custom-theme/my-first-theme/view/layout/default_header_html.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="../../web/css/abc.css"/>
 </head>
 </page>

My css folder path

app/design/frontend/custom-theme/my-first-theme/web/css/abc.css

using above xml file i tried to access abc.css file but not working. Can u please help me for accessing my abc.css file

Abhishek Panchal
4,9643 gold badges22 silver badges39 bronze badges
asked Jan 19, 2018 at 14:46

3 Answers 3

0

change

<css src="../../web/css/abc.css"/>

to

<css src="css/filename.css"/>
answered Jan 19, 2018 at 14:50
0

Your XML file path is Wrong.

app/design/frontend/Vendor/theme/Magento_Theme/layout/default_header_html.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"
 xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <head>
 <css src="css/filename.css" />
 <script src="js/filename.js"/>
 </head>
</page>

Put your JS and CSS file in below path.

app/design/frontend/Vendor/theme/web/css/filename.css app/design/frontend/Vendor/theme/web/js/filename.css

Hope it helps :)

answered Jan 19, 2018 at 15:05
0

Create a file or copy it from parent theme to

app/design/frontend/custom-theme/my-first-theme/Magento_Theme/view/layout/default_header_html.xml

inside this file add entry to your css file as

<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/abc.css" />
 </head>
</page>

Finally, add your abc.css file to the web/css folder of your my-first-theme

Abhishek Panchal
4,9643 gold badges22 silver badges39 bronze badges
answered Jan 19, 2018 at 15:07
1
  • Thanks Abhishek for gave me answer i got css file in pub>static>frontend>custom-theme>my-first-theme>en_US>css>abc.css. But the abc.css link was not showing in web browser Commented Feb 7, 2018 at 7:17

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.