A guide to tokens for common tasks
There are hundreds of tokens available which can provide data for your templates. The specific tokens will differ from website to website, depending on the modules you have installed, the content types and other content entities you have configured and other factors. However, there are some tokens that are likely to be common to most websites. This guide provides examples of common requirements when building templates and example tokens to use.
Text content from your node
- Title field - [node:title] - This will render the title of your node.
- Body field - [node:body] - This will render the body filed of your node. Note: You will often use a 'Field element' to render your Body into your template
Images from your node
There are many tokens available for images. The ones listed below are examples that will be available on a typical Drupal 8 website. When using Image tokens, it's important to remember that the token should be providing a specific piece of data that you will map to a field within a Site Studio element. For example, when mapping an Image to the Image element you will need to map the Image location [node:field_image:entity:path] to the Image upload field within the Site Studio image element.
A common mistake is to try and map the complete Drupal image field [node:field_image] to the Image upload field on Site Studio. This doesn't work because the complete image field includes other data like Alt tag, Title etc.
Here are some example tokens that you might use when mapping Images to Image elements within your templates:
- Example image - [node:field_image:entity:path] - This will render the path to the image
- Example image using Drupal image style - [node:field_image:thumbnail:uri] - This will render an image using the Thumbnail image style
- Image alt text - [node:field_image:alt] - This will render the alt tag of the image
- Image title text - [node:field_image:title] - This will render the title of an image field.
Data about your node
- Date changed - [node:changed] - This will render the date your node was last changed
- Date created - [node:created] - This will render the date your node was created.
- The URL of a node - [node:url] - This will render the URL of a node.