How to display a list of all categories on the home page

How to display a list of all categories on the home page

August 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to display a list of all categories on the home page

Displaying a List of All Categories on the Home Page

As a senior developer, I often receive requests from clients to display a list of all categories on their website’s home page. This not only enhances the user experience but also improves SEO by providing more internal linking opportunities.

Understanding the Problem

The issue you’re facing is quite common when working with Magento. The core problem lies in how you’ve structured your code and how Magento handles block types. Let me break down what’s happening:

  1. You’re correctly using the catalog/navigation block type to display categories.
  2. However, you’re passing a specific category ID (in this case, 2) to the catalog/product_list block.

The issue with your setup is that Magento requires a category ID for the product list block. Since you want to display all categories, there’s no single category ID that applies. This is why your home page becomes blank—Magento doesn’t know which products to display without a valid category ID.

The Solution

To solve this problem, we’ll need to approach it in two steps: displaying the category list and then linking each category to its respective product listing page.

Step 1: Displaying the Category List

We can achieve this by using a different block type that is specifically designed for displaying all categories. In Magento, you would use the catalog/navigation/default block.

Here’s how you can update your code:

{{block type="catalog/navigation" name="catalog.category" template="catalog/category/view.phtml"}}

This tells Magento to display all categories using the default category navigation template.

Step 2: Linking Each Category

Now, let’s link each category to its respective product listing page. We’ll use Magento’s core functionality for this.

First, you need to ensure that your category URLs are set up correctly in the backend (Admin > Catalog > Categories).

Then, you can modify your template file located at vendor/magento/theme-frontend-blank/Magento_Catalog/templates/category/view.phtml.

Find the line where each category is displayed (around line 20). It should look something like this:

<li><a href="{{var category.url}}">{{var category.name}}</a></li>

This line creates a link to the category’s URL using the category.url variable. However, we want to make sure that the URL is formatted correctly with the base URL.

You can achieve this by updating the code like so:

<li><a href="{{store direct_url="catalog/category/view" _query_id=var.category.entity_id}}">{{var category.name}}</a></li>

In this updated line, we’re using Magento’s direct_url function to generate a URL for the current category. The _query_id parameter is set to the category ID (var.category.entity_id), ensuring that each link points to the correct product listing page.

Conclusion

Displaying a list of all categories on your home page requires a bit of tweaking in your code, but it’s quite doable with Magento’s built-in functionality. By using the catalog/navigation/default block and modifying the category URL in the template file, you can create a clean, functional category listing that enhances both user experience and SEO.

Remember, always make sure to backup your files before making changes and test thoroughly after implementation.

For more advanced customizations like this, consider checking out our services at Laravel Company. We specialize in Magento development and can help you optimize your e-commerce platform for better performance and user engagement.

Catalog SEO Errors CLI

Our network