Skip to content
NewRedesigned blogFeedback
Jigar Karangiya

Patch to Debug Blocks and Containers in Magento 2

Today, I will share a patch I created to show comments in the page source. It will not affect the front end and not be visible to customers.

Patch to Debug Blocks and Containers in Magento 2
Written by
JKJigar Karangiya
Published
Reading time
1 min read

Jigar Karangiya · · 1 min read

Hello, In this tutorial we will see how to add comments in the page HTML which shows block and template container names.

Magento provides template hints but its design is too confusing and frustrating. It hurts when you have limited hours to complete your task and are stuck in finding which PHTML file is rendering and which block is responsible for the logic.

Today, I will share a patch I created to show comments in the page source. It will not affect the front end and not be visible to customers.

Please do not use this in the production environment, use it only in your local setup.

You can check comments inside the developer tool of the between and starting of the HTML element.

Let’s check how.

Download my patch from the below URL and put it inside the m2-hotfixes/ or Root Directory.

Apply the patch using ECE-Tools or Simple Git apply Command

./vendor/bin/ece-patches apply

or

git apply DEBUG-COMMENT-BY-JIGAR.patch

If you don’t know how to apply the patch follow the below tutorial :

Magento 2: How to Apply Patch?

Patch Github Link :

https://gist.github.com/jigarkkarangiya/7a99ffd0049b90e7622e2a5e83c9219c (opens in new tab)

It will show the comment on the page below :

Figure 01

That’s it. Now you can easily debug which .phtml file and which block is responsible for rendering the content.

I hope this article helped you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other questions on that.

Do share this trick with your team.

Thank you. Happy Desiging !!

You may also like this :

Magento 2: How to Apply Patch?

Magento 2: How to Get Base URL?

Keep reading
All posts

01 · 10 min · Shares Adobe Commerce Core

Adobe Commerce Agentic Capabilities, Q4 2026

Five agentic releases for Adobe Commerce: LLM product discovery, Brand Visibility, the Shopper MCP server, Brand Concierge, and Experience Workspace. What each one does, which editions get it, and when.

10 min

03 · 3 min · Shares Adobe Commerce Core

Conditions for Collections in Magento 2

Collections in Magento 2 (Now Adobe Commerce), are among the most powerful tools for retrieving and manipulating data directly from the database.

3 min

Newsletter

New Magento tutorials, straight to your inbox

Code examples, performance tips, and fixes for common Magento issues. No spam.

Subscribe