Magento 2: Enable Template Path & Block Class Hints

Template path hints and Block class hints are very useful features for debugging purposes in Magento. This feature helps you to know which template file is being used in any of the Magento pages.

For example, third-party modules can override core template files of any page or any section like header, footer, etc. The template path hints feature will help us figure out the exact template file being displayed in the frontend or backend.

The template path hints & block class type hints features can be enabled or disabled from Magento admin or from command line.

Note:
Please check the IP addresses set in the following field:

STORES > Configuration > ADVANCED > Developer > Developer Client Restrictions > Allowed IPs (comma separated)

– If this field is empty then the template path or block class hints will show for all customers.
– If IP addresses are set in the field then the template path or block class hints will show only for the customers browsing from the specified IP addresses.

Enable Template Path Hints

From Magento admin

Enable template path hints for storefront

STORES > Configuration > ADVANCED > Developer > Enable Template Path Hints for Storefront = Yes
Enable template path hints for backend/admin

STORES > Configuration > ADVANCED > Developer > Enable Template Path Hints for Admin = Yes

From command line

Enable template path hints for storefront

bin/magento dev:template-hints:enable
bin/magento cache:flush
Disable template path hints for storefront

bin/magento dev:template-hints:disable
bin/magento cache:flush

Enable Block Class Type Hints

From Magento admin


STORES > Configuration > ADVANCED > Developer > Add Block Class Type to Hints = Yes

From command line

We have to use n98-magerun2 CLI tool to enable block class hints.

Enable block class type hints

n98-magerun2.phar dev:template-hints:enable
n98-magerun2.phar dev:template-hints-blocks --on
bin/magento cache:flush
Disable block class type hints

n98-magerun2.phar dev:template-hints:disable
n98-magerun2.phar dev:template-hints-blocks --off
bin/magento cache:flush

Hope this helps. Thanks.