4.7.x path.inc drupal_is_front_page()
5.x path.inc drupal_is_front_page()
6.x path.inc drupal_is_front_page()
7.x path.inc drupal_is_front_page()

Check if the current page is the front page.

Return value

Boolean value: TRUE if the current page is the front page; FALSE if otherwise.

2 calls to drupal_is_front_page()
locale_block_view in modules/locale/locale.module
Implements hook_block_view().
_template_preprocess_default_variables in includes/theme.inc
Returns hook-independent variables to template_preprocess().


includes/path.inc, line 284
Functions to handle paths in Drupal, including path aliasing.


function drupal_is_front_page() {

  // Use the advanced drupal_static() pattern, since this is called very often.
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['is_front_page'] =& drupal_static(__FUNCTION__);
  $is_front_page =& $drupal_static_fast['is_front_page'];
  if (!isset($is_front_page)) {

    // As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
    // we can check it against the 'site_frontpage' variable.
    $is_front_page = $_GET['q'] == variable_get('site_frontpage', 'node');
  return $is_front_page;


zenphp’s picture

Just a quick heads up. When hook_boot is fired, this function may not be available.

karlos007’s picture

This function sucks.
I used it in hook_init() and it returns TRUE on cron.php call! Spent several hours to debug that.

dergachev’s picture

I just reported a core issue about its strange behaviour when run in drush or cron context: https://drupal.org/node/2221565

Chi’s picture

Deprecated by path.matcher service.

roynilanjan’s picture

function [MODULE_NAME]_boot() {
  $front_page = variable_get('site_frontpage', 'node');
  //  This always true out of box drupal send blank value of q means this is front -page.
  //  @see drupal_path_initialize().  
  if (empty($_GET['q'])) {    
    $argument = 1 // A dynamic value ;
    $_GET['q'] = "{$front_page}/{$argument}";
blake.thompson’s picture

$is_front_page = \Drupal::service('path.matcher')->isFrontPage();