How do we replace the token  in a custom module?
As already mentioned, &lt;front&gt; is a route, not a token, so you can't use the token API to work with it.

You can resolve it using the Url class:

$path = \Drupal\Core\Url::fromRoute('&lt;front&gt;')-&gt;toString();

// $path is equal to '/'


But I'm not sure how useful that will be. Perhaps you want to get the front page that's set in config instead:

$path = \Drupal::config('system.site')-&gt;get('page.front');