Overriding node output I'm currently creating a website on Drupal 8, even if it's still in RC3.

I've been swimming in the sauerkraut since few days now and I still cannot figure it out how to override node output as I could do in Drupal 7.
Because Drupal 8 is not as used as Drupal 7, it's tough to find answers on Google.

So, I'd like to do the following in my twig file(s):

&lt;div class="images"&gt;
  &lt;ul&gt;
    &lt;?php if ($field_images) { ?&gt;
    &lt;?php
      $img_url = $field_images[0]['uri'];
      $img_alt = $field_images[0]['alt'];
      $img_title = $field_images[0]['title'];
    ?&gt;
    &lt;li&gt;
      &lt;a data-lightbox="galleryWrapper" href="&lt;?php print image_style_url('lightbox', $img_url); ?&gt;"&gt;
        &lt;img src="&lt;?php print image_style_url('album_thumb', $img_url); ?&gt;" alt="&lt;?php echo $img_alt; ?&gt;" title="&lt;?php print $title; ?&gt;" class="media" /&gt;
      &lt;/a&gt;
    &lt;/li&gt;
    &lt;?php } ?&gt;
  &lt;/ul&gt;
&lt;/div&gt;


I've seen that I could, as in Drupal 7, override a template file with a specific filename, such as: "field--node--field-images--gallery.html.twig".

The thing is that I don't know where to create my variables that will be available for my twig files (MYTHEME.theme?).

I've already tried this in "field--node--field-images--gallery.html.twig":

{% if multiple %}
  &lt;div{{ attributes.addClass(classes, 'field__items') }}&gt;
    {% for item in items %}
      &lt;div{{ item.attributes.addClass('field__item') }}&gt;
        {#  Before was {{ item.content }} instead of the 5 following lines  #}
        {% if item.content.url %}
          &lt;a href="{{ item.content.url }}" class="lightbox" data-lightbox="gallery"&gt;{{ item.content.image }}&lt;/a&gt;
        {% else %}
          {{ item.content.image }}
        {% endif %}
      &lt;/div&gt;
    {% endfor %}
  &lt;/div&gt;
{% else %}
  {% for item in items %}
    &lt;div{{ attributes.addClass(classes, 'field__item') }}&gt;
      {#  Before was {{ item.content }} instead of the 5 following lines  #}
      {% if item.content.url %}
        &lt;a href="{{ item.content.url }}" class="lightbox" data-lightbox="gallery"&gt;{{ item.content.image }}&lt;/a&gt;
      {% else %}
        {{ item.content.image }}
      {% endif %}
    &lt;/div&gt;
  {% endfor %}
{% endif %}


I've tried to access to "url" with {{ item.content.url }}, because {{ content }} seems to call "image-formatter.html.twig", which contains the following:

{% if url %}
  &lt;a href="{{ url }}"&gt;{{ image }}&lt;/a&gt;
{% else %}
  {{ image }}
{% endif %}


As you can imagine, it doesn't work.

And, that's another issue, but I've already tried to dump variables but I got this famous WSOD (White Screen Of Death). So, that's very difficult to know what this $variables contains.
The fields you are looking for are under '#item', for example:

 {{ item.content['#item'].title }}


To set variables for twig put a theme_preprocess_field() function in  MYTHEME.theme.

To examine variables use kint (this is in the devel module):

{{ kint() }}
{{ kint(items) }}