Skip to main content
1 of 2
4uk4
  • 101.7k
  • 7
  • 173
  • 217

The node title already has a token, you can see this, if you install the token module: https://www.drupal.org/project/token

This is only an alpha version, but it is OK to use it.

Go to the help page of the module and you will see that the node title is already there:

[node:title]

You can use this token only in a node context. If you use it outside of this, for example in a block, you have to add a cache context in this block:

$build['#cache']['contexts'][] = 'url.path';
4uk4
  • 101.7k
  • 7
  • 173
  • 217