Twig allows us to print variables by simply referencing them within our document using the {{ variable }} syntax to trigger the interpreter, in order to replace the variable name with the value stored in it. We can try this by replacing the word Twig in our heading with the name variable.
Open page.html.twig and add the following:
{# Setting a variable #} {% set name = 'Drupal' %} {# This is a comment in Twig #} <h1>Welcome to {{ name }}</h1>
If we save our template and refresh the browser, we will see that our heading now says Welcome to Drupal. The name variable we set has output the word Drupal in its place. This is the same technique that we would use to output variables in Twig templates to display content from Drupal.
In fact, if we sneak a peek at our html.html.twig template, we will see a variety of Twig variables being used to output content.