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:
php bin/magento dev:template-hints:enable
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.
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!
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.