How to Enable Template Path Hints in Magento 2

How to Enable Template Path Hints in Magento 2

The life of a developer ain’t easy!

Any tutorials or methods that can ease their tasks are always welcomed! Hence, here’s one of them, to enable template path hints in Magento 2. It makes it easier to locate a particular .phtml file.

Template path hints in Magento 2 are the tiny tags shown in the frontend to locate the code within the Magento file structure. Content on storefront pages is displayed using the .phtml files. To make the changes in the content, .phtml files require to be edited. And to edit or update .phtml files, the very first step is to locate them.

However, in the complex file structure, the below methods make it easy to trace specific .phtml files by enabling template path hints in Magento 2.

Methods to Enable Template Path Hints in Magento 2:

  1. Via Admin Panel
  2. Via Command Line

Follow any of the below methods to enable template path hints in Magento 2:

Enable Template Path Hints via Admin Panel:

  • Log in to Admin Panel
  • Navigate to Stores > Configuration > Advanced > Developer
  • Expand “Debug”  and set YES to “Enable Template Path Hints for StoreFront
  • Also, under “Developer Client Restrictions, enter the IP address in the field “Allowed IPs” for which you want to enable the template path hints.
  • Save the configuration.Backend - enable template path hint in Magento 2

Once you follow the below steps, you can see the frontend as shown below where the template path hints are enabled for you to easily trace the .phtml files and edit it!

Frontend - template path hints enabled in Magento 2

Enable Template Path Hints via Command Line:

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

Enable template path hints for frontend:

Disable template path hints for frontend:

Clean and flush cache:

Note: You can’t enable or disable template path hints for the admin using this method.

You can also refer to the video tutorial to Enable Template Path Hints in Magento 2 from our Magento 2 video tutorial series:

How to Enable Template Path Hints in Magento 2 1

That was all about template path hints in Magento 2 to make the life of developers a bit easier 😄

Any queries in the topic are welcome in the Comments section below.

Do rate the post with 5 stars if it was helpful for you!

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 20 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a reply:

Your email address will not be published.