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.
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.
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.
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.
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.
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.
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.
Connect to your store with SSH terminal, and go to the root directory of your Magento 2 store.
php bin/magento dev:template-hints:enable
php bin/magento dev:template-hints:disable
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.
Read More:It is a feature that helps developers see which template file is used for a specific part on any webpage.
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.
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.
Yes, you can do so easily. All you need to do is set Enable hints for Storefront with URL Parameter to Yes.
This blog was created with FME's SEO-friendly blog