PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Template Basic

Detect Whether the Current Page Is the Home Page (Multilingual-Safe)

Compares the active menu item against the default menu item for the active language tag via $menu->getDefault($langTag).

Updated on 24 November 2026 65 copies 226 views
templates/seu_template/index.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;

$app     = Factory::getApplication();
$menu    = $app->getMenu();
$langTag = $app->getLanguage()->getTag();
$active  = $menu->getActive();
$default = $menu->getDefault($langTag);

$isHome = ($active !== null && $default !== null && (int) $active->id === (int) $default->id);
Works identically on single-language and multilingual Joomla websites.
templates/seu_template/index.php
<?php
$app  = JFactory::getApplication();
$menu = $app->getMenu();
$lang = JFactory::getLanguage();

$isHome = ($menu->getActive() == $menu->getDefault($lang->getTag()));
Classic Joomla 3 snippet via JFactory::getLanguage()->getTag().

Technical explanation and best practices

On multilingual sites, each content language defines its own Home menu item. Passing $app->getLanguage()->getTag() into $menu->getDefault() guarantees accurate Home detection across all languages.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.