Source: How to check IsHomePage in Magento 2? Are we on the homepage?
1 2 3 |
<?php if ($this->getRequest()->getFullActionName() == 'cms_index_index') : ?> <h1>you are on the homepage</h1> <?php endif; ?> |
1 2 3 4 5 6 7 8 9 |
if ($this->getRequest()->getFullActionName() == 'cms_index_index') { //you are on the homepage } if ($this->getRequest()->getFullActionName() == 'catalog_product_view') { //you are on the product page } if ($this->getRequest()->getFullActionName() == 'catalog_category_view') { //you are on the category page } |