How to check if the page is front page? The following method not returning any value (true or false).

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


How to check if the page is front or not?
This is indeed a way to check if it is the front page and should return a value if you check the method code.

I am using it in a few preprocess hooks:

$variables['is_front'] = \Drupal::service('path.matcher')-&gt;isFrontPage();