How To Check If Current Page Is Homepage In Magento

It's only fair to share...Share on Facebook0Share on Google+5Tweet about this on Twitter0Share on LinkedIn4Pin on Pinterest0Digg thisShare on StumbleUpon0

magento home page checker

Some time we required any specific functionality on the homepage of Magento. In this article I am going to explain basic code for Magento through which we can identify the page on which we have. If we like some js, css or image files need to be loaded on home page only. Of course we can achieve this by XML file in Magento but the thing is below conditions will be useful when we really need it.

If we are in template/page/html/header.phtml template file, then we can check for homepage with the below code:

If we are in any other .phtml template file or other .php class file then we can use the following code:

Alternative way to check for homepage:


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">