Template path hints in Magento 2 are the tips that help you define a .php block class or a .phtml template that corresponds to a specific page area on your Magento 2 store. In other words, template path hints add a notation with the path of each template to help you to locate the .phtml files easier and edit them faster correspondingly. You can locate the code in the Magento file structure both on the frontend and the admin.

So, let's find out the methods you can enable the Magento 2 template path hints with.

Magento 2 Template Path Hilts

Enable Template Path Hints from the Admin Panel

In order to enable template path hints in Magento 2 follow these steps:

1. Make sure your Magento 2 is in the default or developer mode.

2. Go to Admin Panel > Stores > Settings > Configuration > Advanced > Developer > Debug.

Magento 2 Template Path Hints

3. Check and configure Developer Client Restrictions.

Magento 2 Template Path Hints Client Restrictions

In this section set one or several IPs you want Template Path Hints to be available to. You can enable template path hints (next step), but still, you won't see them if in Allowed IPs there is some other IP entered.

This is done in case you want to look something up without disturbing other developers or customers since leaving this section empty will allow template path hints to everyone currently using the website.

4. Enable Template Path Hints.

Choose whether you want it to be enabled for StoreFront or Admin. Select Yes in the Add Block Names to Hints select box in case you want template path hints to show a block PHP class name additionally to PHTML template file path.

Magento 2 Template Path Hints Debug

5. Once you have finished don't forget to press the Save Config button.

Magento 2 Template Path Hints Save Config

6. Before using Template Path Hints we recommend you make sure that Magento block cache, page cache are disabled.

 Now you are ready to reload a page to see which blocks on a page are referred to which PHP/PHTML files.

There is one more way you can enable the template path hints for your Magento 2 store.

Enable Template Path Hints using Command Line Interface

Note: unlike the previous method, using CLI you can enable or disable template path hints for Magento 2 storefront only.

To enable template path hints in Magento 2 run the following command:

php bin/magento dev:template-hints:enable

In order to disable template path hints use this command:

php bin/magento dev:template-hints:edisable