0

I need to create custom.css file using local.xml. I tried adding this command <action method="addCss"><stylesheet>css/custom.css></stylesheet></action> to local.xml file but it doesn't do anything, I can't edit my page. I'm not even sure where the custom.css saves. Could somone tell me the steps to do this with paths to the files?

2

What @kothari posted will work, but since I can't comment on his answer, I'll answer your question about where it looks for it here.

Basically what this does:

<default>
     <reference name="head">
         <action method="addCss"><stylesheet>css/custom.css</stylesheet></action>
    </reference>
</default>

Is it tells Magento to add the CSS in this file path:

http://yourwebsite.com/skin/frontend/$package/$theme/css/custom.css

$package and $theme referring to the active package and theme. For example, if you're using the default base theme, this would resolve to:

http://yourwebsite.com/skin/frontend/base/default/css/custom.css

It does NOT create the CSS file for you, you have to create that CSS file and add it to that folder.

1

Try this, in your local.xml

<default>
         <reference name="head">
             <action method="addCss"><stylesheet>css/custom.css</stylesheet></action>
        </reference>
    </default>
  • Thank you, but I can't find it. Do I need to create it? and if so whats the path? – Rufas Dec 14 '16 at 19:57
  • First check page source it will call or not – Magento 2 Dec 15 '16 at 4:34
0

Adding new CSS

<theme-dir>/blank/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/newtheme.css" />
    </head>
</page>

Remove static resources (JavaScript, CSS, fonts) To remove the static resources, linked in a page , make a change similar to the following in a theme extending file app/design/frontend///Magento_Theme/layout/default_head_blocks.xml

<head>
    <!-- Remove local resources -->
    <remove src="css/styles-m.css" />
    <remove src="my-js.js"/>
    <remove src="Magento_Catalog::js/compare.js" />

<!-- Remove external resources -->
    <remove src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css"/>
    <remove src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"/>
    <remove src="http://fonts.googleapis.com/css?family=Montserrat" /> 

http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-manage.html#layout_markup_css_remove

  • the question is for M1.9 but your answer is for M2 – fmsthird Mar 27 at 5:58

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.