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:
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.
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!
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:
1 |
php bin/magento dev:template-hints:enable |
Disable template path hints for frontend:
1 |
bin/magento dev:template-hints:disable |
Clean and flush cache:
1 |
bin/magento cache:clean |
1 |
bin/magento cache:flush |
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:
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.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
Prev
How to Disable Password Expiration in Magento 2
How to Add New Category and Product in Magento 2
Next