How to Enable Template Path Hints in Magento 2? The Right Way

How to Enable Template Path Hints in Magento 2? The Right Way

In this tutorial, we will see how to enable template path hints in Magento 2. By enabling "Template Path Hints", you can see exactly which file a particular area of the page is created from. This makes it easy to locate a particular .phtml file and update it to make changes in the specific content on the storefront.

Why Should You Use Magento 2 Template Path Hints?

Magento 2 Template Path Hints is the part of the Debug process while developing a webshop. Template Path Hints adds notation with the path to each template and displays the errors directly on the screen. This is one of the best ways to debug your store.

Enabling Template Path Hints in Magento

Template path hints can be enabled for either the storefront or the Admin. If Magento 2 template hints are not showing on storefront, then you can use any of the following two methods to fix this problem.

template path hints in magento

Method 1: Enable Template Path Hints in Magento 2 Via Admin Panel

  • Login to your Admin panel
  • Navigate to Stores -> Configuration -> Advanced -> Developer
  • Expand the "Debug" section

Enable Template Path Hints for Storefront

  • To enable template path hints for the Storefront, set “Enable Template Path Hints for Storefront” to Yes.
  • To enable hints for storefront with url parameter, set Enable hints for Storefront with URL Parameter to Yes.

Make sure to Clear Magento Cache if template path hints for storefront are not working.

Enable Template Path Hints for Admin

  • To Enable template path hints for the Admin, set Enabled Template Path Hints for Admin to Yes.
  • Click "Save Config"
  • Now Clear Magento Cache: On the Admin sidebar, go to System -> Tools -> Cache Management -> click Flush Magento Cache.

enabling template path hints

If you refresh your front end view (your website) you should now see Template Path Hints enabled for you and you can easily trace the .phtml files and edit it.

Method 2: Enable Magento 2 Template Hints via Command Line

Connect to your store with SSH terminal, and go to the root directory of your Magento 2 store.

To Enable Template Hints via CLI:

	php bin/magento dev:template-hints:enable

To Disable Template Hints via CLI:

	php bin/magento dev:template-hints:disable

Clear Cache via CLI:

Make sure, you clear Magento 2 cache if Magento 2 template hints are not showing.

Clear Magento Cache to remove all hints from the store using the following command:

	bin/magento cache:flush

That’s all about enabling template path hints in Magento 2. This is as straightforward as it seems. However, no question is a wrong question so don’t hesitate to contact us in case you have any questions related to template path hints in Magento 2.

Related Articles: