Checking if the current page is the homepage in Drupal 8 - not using drupal_is_front_page
Mike Dixon
Senior Mind
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?
We will keep this one short and sweet. There is quite a bit of documentation pointing to the fact that drupal_is_front_page() still exists in Drupal 8 ... it doesn't!
Panic not. The solution is nice and easy, the following snippet will act as a drop in replacement for drupal_is_front_page() - simply returning TRUE or FALSE.
\Drupal::service('path.matcher')->isFrontPage();