Where can I find a list of the available tokens, so I can write things like {{ node.title }} in my templates?

The documentation says the best way to find a list of them is to use this: https://www.drupal.org/docs/8/modules/d8-rules-essentials/data-selection

Can anyone provide something more useful?

  • 4
    Possible duplicate of How do I check the content of variables passed to a template file?
    – ya.teck
    Commented Oct 3, 2019 at 13:23
  • Not quite a duplicate, but I think that's a very useful question/answer combo. Drupal core (and hopefully contrib.) templates are inline code documented (either open the base template, found using twig debug, or look it up on api.drupal.org) with the potential variables available. These aren't "tokens", which are a different thing and perhaps why you went down the rabbit hole of looking at Rules module documentation.
    – mradcliffe
    Commented Oct 4, 2019 at 11:53

1 Answer 1


Those are variables, not tokens. They're arbitrary, and can/will change depending on what template you're in, what modules/themes you have installed, and how you have them configured.

The easiest way to see what variables you have available in context is to use the dump() method:

{{ dump() }}

See Discovering and Inspecting Variables in Twig Templates for full details.

  • Should I re-word the question to use 'variables' then?
    – Innovine
    Commented Oct 3, 2019 at 13:00
  • It's up to you really, I think there's value in leaving it (for future visitors) and also value in changing it
    – Clive
    Commented Oct 3, 2019 at 13:27
  • I am still having trouble with this. I tried {% for key, value in _context %} and get a list, including "page", but I haven't managed to get the sub items in page. What I really want to do, is determine the first part of the URL after the host, ie when on htttp://server/target/pagename it should return 'target'... is this or the full path stored in one of these variables?
    – Innovine
    Commented Oct 4, 2019 at 7:27
  • I don’t think so, but you can easily add a preprocess function to provide it
    – Clive
    Commented Oct 4, 2019 at 7:37
  • I eventually came across {{ path('<current>') }} but before that I learned quite a lot about preprocess functions, so thanks for that!
    – Innovine
    Commented Oct 4, 2019 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.