Skip to main content
Stéphane Quantin

Main navigation

  • Portfolio
  • About
  • Freelance Drupal
    • Audit de site Drupal
    • Drupal maintenance contract
  • Blog
  • CV
  • Contact
Languages
  • French
  • English

Breadcrumb

  1. Home
  2. Blog

Drupal 8: programmatically test if the current page is the home page of the site

 To test programmatically if the current page is the home page of the site on a Drupal 8 site, you can use the following code:

\Drupal::service('path.matcher')->isFrontPage()

The method will return TRUE if the current path is the home page, and FALSE otherwise.

Tags

  • Drupal 8

Social networks

  • Malt
  • codeur.com
  • 404Works
  • LinkedIn
  • Twitter
  • DoYouBuzz

Tweets by StephaneQ

RSS feed

Pied de page

  • Contact
  • Mentions légales
Powered by Drupal