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

0

change

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

to

<css src="css/filename.css"/>
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 :)

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

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 – Shiva Reddy Feb 7 '18 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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