Twig can also assign values to variables using a technique named assignment. Assignment uses the set tag to place a value into a variable, which can then be used later within a template to output the value.
Open page.html.twig and add the following above our heading:
{# Setting a variable #} {% set name = 'Drupal' %} {# This is a comment in Twig #} <h1>Welcome to Twig!</h1>
If we save our template and refresh the browser, we will not see any changes to our HTML as we are only setting a variable but not using it anywhere in our document. So how do we then use a variable?