Magento: How to check if current page is homepage?

Magento: How to check if current page is homepage?
Magento: How to check if current page is homepage?

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

if($this->getIsHomePage()) {
    echo 'You are in Homepage!';
} else {
    echo 'You are NOT in Homepage!';
}

Below is an alternative way to check for homepage:-

$routeName = Mage::app()->getRequest()->getRouteName();
$identifier = Mage::getSingleton('cms/page')->getIdentifier();
 
if($routeName == 'cms' && $identifier == 'home') {
    echo 'You are in Homepage!';
} else {
    echo 'You are NOT in Homepage!';
}

Hope this helps. Thanks.