how to create image slider for homepage in magento?

how to create image slider for homepage in magento?

July 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
how to create image slider for homepage in magento?

Adding an Image Slider to Your Magento Homepage

In this guide, we’ll walk you through the process of creating an image slider for your Magento homepage using the MA2 theme.

Prerequisites

Before we begin, make sure you have:

  1. A running Magento installation (version 1.9 or later)
  2. The MA2 theme installed and enabled
  3. Some images prepared for the slider (they should be of similar dimensions)

Step 1: Create a new CMS page

We’ll first create a new CMS page that will hold our image slider.

  1. Log into your Magento admin panel.
  2. Navigate to CMS > Pages.
  3. Click on the “Add New Page” button at the top right corner.
  4. Fill in the required details:
    • Title: Homepage Image Slider
    • Content: (Leave this empty for now)
  5. Set the Status to Enabled and click Save.

Step 2: Add content to the CMS page

Next, we’ll add some HTML and CSS to create our basic slider structure on the CMS page.

  1. Edit the “Homepage Image Slider” page you just created.
  2. In the Content field, paste the following code:
<div class="slider-container">
  <div id="slider">
    <img src="{{media url='path/to/your/image1.jpg'}}" alt="Image 1">
    <img src="{{media url='path/to/your/image2.jpg'}}" alt="Image 2">
    <!-- Add more images as needed -->
  </div>
</div>

Make sure to replace path/to/your/image1.jpg and image2.jpg with the actual paths to your images.

  1. Click Save Content.

Step 3: Add JavaScript for the slider

Now, we’ll add some JavaScript (using jQuery) to make our static images into an interactive slider.

  1. Open your theme’s main layout file (app/design/frontend/{package}/{theme}/layout/page.xml). Look for the <reference name="head"> section.
  2. Inside this section, paste the following code:
<action method="addItem">
  <type>skin_js</type>
  <name>js/jquery.slider.min.js</name>
  <params />
</action>
  1. Save and close the file.

Step 4: Add CSS for styling

Finally, we’ll add some basic CSS to style our slider.

  1. Open your theme’s main CSS file (app/design/frontend/{package}/{theme}/css/style.css).
  2. At the bottom of the file, paste the following code:
.slider-container {
  position: relative;
  overflow: hidden;
}

#slider {
  display: flex;
  animation: slide 30s infinite;
}

#slider img {
  width: 100%;
}

@keyframes slide {
  0% { transform: translateX(0); }
  25% { transform: translateX(-100%); }
  50% { transform: translateX(-200%); }
  75% { transform: translateX(-300%); }
  100% { transform: translateX(0); }
}

Step 5: Include the CMS page in your homepage

The final step is to include our new CMS page on the homepage.

  1. Open app/design/frontend/{package}/{theme}/layout/cms_index_index.xml.
  2. Look for the <reference name="content"> section.
  3. Inside this section, paste the following code:
<block type="cms/block" block_id="homepage_image_slider">
  <action method="setBlockId"><block_id>homepage_image_slider</block_id></action>
</block>

Conclusion

That’s it! You should now see an image slider on your Magento homepage.

Remember, this is a basic setup and you can customize the CSS further to match your theme’s design. You might also want to consider using more advanced slider plugins for better functionality.

At Laravel Company [https://laravelcompany.com], we specialize in providing high-quality themes and extensions for Magento, including advanced sliders that are easy to configure and offer a wide range of customization options.

If you found this guide helpful, be sure to check out our selection of premium Magento themes at the link provided.

Magento 1 Themes Admin JavaScript

Our network