use custom template file for magento homepage and product page

use custom template file for magento homepage and product page

July 23, 2026 · Illustrated author avatarBy Stefan Bogdanescu
use custom template file for magento homepage and product page

Customizing Magento Templates for Homepage and Product Pages

Magento is a powerful e-commerce platform that allows you to customize your store’s appearance using themes and templates. In this guide, we’ll show you how to use custom template files for the Magento homepage and product pages.

Step 1: Creating Custom Templates

Let’s start by creating our custom template files:

  • Homepage Template (home.phtml): Create a new file named home.phtml inside your theme directory under app/design/frontend/your_package/your_theme/template/page/.
<!-- app/design/frontend/your_package/your_theme/template/page/home.phtml -->
<div class="custom-homepage">
    <h1>Welcome to Our Custom Homepage!</h1>
    <!-- Your custom homepage content here -->
</div>
  • Product Page Template (product.phtml): Create another file named product.phtml inside the same directory.
<!-- app/design/frontend/your_package/your_theme/template/page/product.phtml -->
<div class="custom-product-page">
    <h2><?php echo $this->getProduct()->getName() ?></h2>
    <!-- Your custom product page content here -->
</div>

Step 2: Modifying the Layout

Now, let’s modify the layout XML file to apply these templates:

  • Open your theme’s local.xml file located at app/design/frontend/your_package/your_theme/layout/local.xml.
<!-- app/design/frontend/your_package/your_theme/layout/local.xml -->
<layout version="1.0">

    <cms_index_index>
        <reference name="root">
            <action method="setTemplate" template="page/home.phtml"/>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </cms_index_index>

    <catalog_product_view>
        <reference name="root">
            <action method="setTemplate" template="page/product.phtml"/>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </catalog_product_view>

</layout>

Step 3: Removing Cart and Compare Boxes from Homepage Sidebar

To remove the cart and compare boxes only from the homepage sidebar, you can use the following code in your theme’s local.xml:

<cms_index_index>
    <remove name="right"/>
</cms_index_index>

This will remove all blocks in the right sidebar (which typically contains the cart and compare boxes) for the homepage.

Step 4: Testing Your Customizations

Save your changes, clear any cache files, and then navigate to your Magento store. You should now see your custom templates applied to the homepage (home.phtml) and product pages (product.phtml).

For more advanced theming and templating techniques, consider exploring resources like LaravelCompany for detailed tutorials and best practices.

Conclusion

In this guide, we’ve demonstrated how to create custom template files and apply them to the Magento homepage and product pages using layout XML. By following these steps, you can achieve a unique look and feel for your store while maintaining the core functionality of Magento.

Remember that theme development is an iterative process. Regularly test your changes in a staging environment before deploying them to your live site. Happy coding!

Catalog Themes Configuration

Our network