magento 2 how to display the category product in homepage?

magento 2 how to display the category product in homepage?

July 22, 2026 · Illustrated author avatarBy Stefan Bogdanescu
magento 2 how to display the category product in homepage?

Displaying Category Products on Magento 2 Homepage

Updating from Magento 1.x to 2.x often requires adjusting your codebase to adapt to the new architecture and development practices introduced in version 2. One common issue faced by users is that previously working blocks, like the product list block used for displaying category products on the homepage, no longer function as expected.

The Problem with Magento 1 Code

The provided code from the old version of Magento uses a deprecated syntax:

{{block type="catalog/product_list" column_count="4" category_id="13" template="catalog/product/list.phtml"}}

In this context, type refers to a block type which no longer exists in Magento 2. The category_id attribute is also outdated as the new system uses category IDs differently.

Solving the Issue in Magento 2

To display products from a specific category on your home page in Magento 2, you’ll need to use a new approach:

  1. Create a Static Block

    First, create a static block that will be used to display the product list. Navigate to Content > Elements > Add New Block. Name it something like “Homepage Category Products”.

  2. Add the Product List Content

    In the content area of your new block, add the following code:

<div class="category-products">
    {{widget type="Magento\Catalog\Block\Product\Products" category_id="13" column_count="4" template="Magento_Catalog::product listing.phtml"}}
</div>

Understanding the New Code

  • type: We’re using the Magento\Catalog\Block\Product\Products block type.
  • category_id: Here, you specify the ID of the category whose products you want to display. You can find these IDs in the admin panel under Products > Categories.
  • column_count: Sets the number of columns for your product list layout (4 in this example).
  • template: Specifies the template file to use.

Incorporating the Block into Your Homepage

To add this block to your homepage, you have two options:

Option 1: Using the CMS Content

Go to Content > Pages and edit your home page. In the content area, switch to the ‘HTML Editor’ view (if available), or use the HTML source code editor if not.

Find where you want to place the block and paste this code:

{{block class="Magento\Cms\Block\Block" block_id="homepage_category_products"}}

Replace homepage_category_products with the actual ID of your static block (you can find it in the admin panel under Content > Elements).

Option 2: Using a Theme Layout XML Update

If you’re comfortable editing layout XML files, you can add this directly to your page layout.

In your app/design directory, navigate to your active theme’s folder. Then go to Magento_Theme > templates/page/html and open the header.phtml file. Find the section where you want to insert the block (usually in the main content area), and add:

{{block class="Magento\Cms\Block\Block" block_id="homepage_category_products"}}

Conclusion

Displaying category products on the homepage requires a different approach in Magento 2 compared to version 1.x. By creating a static block and using the new widget syntax, you can easily add product lists to any page.

Remember that this is just a basic example. You may want to customize the output further by adjusting the template or using additional parameters for the widget. For more advanced customizations, consider exploring Magento 2’s layout XML updates and widget settings documentation for a deeper understanding of how to manipulate content on your pages.

With this guidance, you should now be able to successfully display category products in the homepage of your Magento 2 store. Happy developing!

Magento 2 Magento 1 Catalog Themes

Our network