Home » Magento22 November 2010

Magento: How to check if current page is homepage?

Here is a quick Magento code to check if the current page is homepage or not.

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

If you are elsewhere (in any other .phtml template file or in any other .php class file) then you can use the following code:

Below is an alternative way to check for homepage:-

Hope this helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • getIsHomePage works strange. It’s returning false when i.e. customer is changing store view and actually he land on home page (but with some __store parameter).

  • Colid

    in what file exactly can i paste the code sir ?

    ‘coz my problem is,
    I want to detect if Im on the homepage and do certain CSS rules for that. hmmm. can you help me ? :)

  • Umesh

    Helpful ! Thanks :)

  • Manish

    thanks its really helpful

  • nikhilravindran

    very help ful thanks a lot ! ! !

  • Ricardo

    Google chrome and Firefox works strange too.

  • shirtsofholland

    We use

    We use

    $route = Mage::app()->getFrontController()->getRequest()->getRouteName();

    $action = Mage::app()->getFrontController()->getRequest()->getActionName();

    if($route == ‘cms’ && $action == ‘index’):

    echo $this->getChildHtml(‘shopper_footer_partners’);


  • the second one works in a snap. Thanks! :D