Magento 2E-CommerceHow To GuideJuly 12, 2024Simon Walker

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

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

If you are a Magento developer, then you’ll benefit from this article greatly as we are going to discuss everything there’s to know about Magento 2 template hints. Before we discuss how to enable template path hints in Magento 2, let’s understand what Magento 2 template hints are and how it benefits the developers.

What are Magento 2 Template Hints?

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. Now, let’s turn our attention towards the benefits.

Why Should You Use Magento 2 Template Path Hints?

Quick Debugging

The topmost reason merchants use Magento is because of its customisability. Naturally, when considerable custom work is done, there are chances of bugs. Enabling the Magento 2 template hints allows developers to see which template file is used to render a specific part of the webpage. This speeds up the process of identifying and fixing coding issues.

Saves Time

If you need to make changes to your store, then developers require considerable time to browse through directories to find the relevant template files. When the template path hints are enabled, developers can easily pinpoint the exact file they need to modify, thereby speeding up the development process.

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. Keep in mind that after enabling the Magento 2 template path hints, your website will slow down significantly. Therefore, only enable this feature in development mode. For more information, refer to our guide on how to set Magento 2 modes.

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

Final Thoughts on Magento 2 Template Hints

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.

Read More:

FAQs About Magento 2 Template Path Hints

1. What are template path hints in Magento 2?

It is a feature that helps developers see which template file is used for a specific part on any webpage.

2. What to do if Magento 2 template hints not showing?

If the template path hints are not showing, then repeat the above steps again. Ensure that you clear the cache. In most cases, users forget to clear the cache.

3. Are there any security concerns related to showing template hints?

If you enable the template path hints in production mode, then users can see the internal structure of your store. This information is sensitive and can be misused.

4. Can I enable template paths for specific URLs?

Yes, you can do so easily. All you need to do is set Enable hints for Storefront with URL Parameter to Yes.