not all tokens are replaces in a twig template

Created on 23 March 2024, 8 months ago
Updated 2 May 2024, 7 months ago

Hello,
I started working on twig templates only recently and was now trying to get some functionality that I use in content nodes to also to get to work in a twig template.
In my content I use tokens, such as:

[site:name]
[language:langcode]
[node:field_land]
[node:title]

These are all replaced successfully in my output.

I have installed the twig tweak module and I used the following context for these same token replacements:

{{ drupal_token('site:name') }}
{{ drupal_token('language:langcode') }}
{{ drupal_token('node:field_land') }}
{{ drupal_token('node:title') }}

The first two token are replaced succesfully (site name and language code)

But the third and fourth ones are not. One is a custom field that was added to this content type the other one is the node title, which is a default field for any content type.
So this token is in the system and is replaced in my basic-html content when used in a regular node but not when using it in a twig template.
I get this as output:

TestSite
en
[node:field_land]
[node:title]

Any thoughts on what I need to do to get this to work?

💬 Support request
Status

Fixed

Version

3.3

Component

Code

Created by

🇳🇱Netherlands RobBNL

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024