Categories: Magento

How to Add Javascript And CSS To Home Page or specific CMS page in Magento .?

Magento Add Custom CSS and Javascript to Home Page or specific CMS page

Magento is a complete package and allows custom changes to its layout with easy addition of custom CSS and JS files respectively. Even if you want to add specific Custom CSS and JS to any particular CMS page then you can use these steps to change the design. Here are the steps by which you can add custom CSS or JS to any Magento CMS page or Homepage to override from the default one.


Steps for adding Custom CSS or JS in Magento

  • Step 1. Login to your store back end/admin panel with suitable credentials
  • Step 2. Navigate to the CMS > Pages and click on the page for which you want to add the Custom Javascript or Style CSS for making specific changes.
  • Step 3. Now Click on the Design Tab From the Left Side bar
  • Step 4. Select your Page Layout from the drop down.
  • Step 5. In the Field “Layout Update XML” Put the code below as per your requirement and change the file name with your actual file name.

Magento Add Custom CSS:
<reference name="head">
  <action method="addItem">
    <type>skin_css</type><script>Your_CSS_File_Name.css</script>
  </action>
</reference>

OR

<reference name="head">
  <action method="addCss">
    <type>skin_css</type>
    <stylesheet>Your_CSS_File_Name.css</stylesheet>
  </action>
</reference>

OR

<reference name="head">
 <action method="addCss">
  <stylesheet>Your_CSS_File_Path/Your_CSS_File_Name.css</stylesheet>
 </action>
</reference>

Magento Add Custom JavaScript:
<reference name="head">
  <action method="addItem">
    <type>skin_js</type><script>Your_JavaScript_File_Name.js</script>
  </action>
</reference>

OR

<reference name="head">
  <action method="addJs">
    <type>skin_js</type>
    <script>Your_JavaScript_File_Name.js</script>
  </action>
</reference>

OR

<reference name="head">
 <action method="addJs">
   <script>Your_JavaScript_File_Path/Your_JavaScript_File_Name.js</script>
 </action>
</reference>

Rohan pathak

Recent Posts

What Is a Progressive Web App? Why Would You Need One?

App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…

1 year ago

7 Most Popular Paid Online Advertising Strategy

As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…

1 year ago

The Importance of User-Centered Design in Mobile App Development

Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…

1 year ago

Healthcare Mobile App Development: A Complete Guide for Founders

COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…

1 year ago

Exploring Diverse WordPress Theme Niches: A Comprehensive Guide

Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…

1 year ago

8 Awesome Blog Content Ideas for Movers to Skyrocket the SEO

For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…

1 year ago