I'm trying to understand the templating system of Drupal 8, allready did some basic stuff. My next step is trying to create a template to mark up a list generated by a view.

Here's what I've done so far:

I created:

  • A Content Type, with 3 fields: Title, Body, Link
  • Some (5) content entries with this Content Type
  • A View (Block) that lists all of the entries of this Content Type.

In Block layout I placed the View-block in a custom Region (werk_items) (configured in the my-theme.info.yml file.)

Than I created a page template (page--node--23.html.twig) that includes this region, like so

{{ page.werk_items }}

When I go to the corresponding URL all works well and all of the content is displayed.

Now my question is: How to extract the variables to create a custom markup for the view content?

2 Answers 2


If you want to create custom markup/template for that particular view of content type then create file and name it as views-view-fields--[view-name]--page/block.html.twig and save it in template directory of your theme.

Now to get the variable just goto the content type -> manage fields. There you will find the machine names of fields. those are the variable you need to place in html structure like this
{{ fields.field-machine-name.content }}
Hope this helps :)


If you want to see all the variables available in the Twig template you can just call dump Twig function without any parameters:

{{ dump() }}

In case you want to modify the markup inside the region or the blocks you should override corresponding templates instead of trying to modify the render array inside your page template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.