Programmatically use token filter
Data about the node needed to be supplied as a parameter to the replace method.
It worked once I used

$node = \Drupal::routeMatch()-&gt;getParameter('node');
$vars['label'] = $token-&gt;replace($vars['label'],['node' =&gt; $node]);