How can I embed a view inside a content of a node in Drupal 8?

I found something similar, for example in the question about "How do I embed a view inside a node?" or the Viewfield module, but it is all for Drupal 7.

I tried with an Entity reference field pointing to a View but it display only a label and from the Manage Display tab I can choose only from Label and Entity ID. I need something like the "Rendered entity" option that is present on Entity reference fields pointing to other nodes.

enter image description here

5 Answers 5


Option 1

You can create a View Block. Then the view block will be available in the blocks section /admin/structure/block. Assign the view block to a region and show it on specific pages if you need to.

enter image description here

Option 2

Create a twig template file for your node and use

Twig Tweak

Twig Tweak module provides a Twig extension with some useful functions and filters that can improve developer experience.

Ex: {{ drupal_view('view_name', 'block_1') }}

Option 3

If you use Panels or Display Suite, you can embed the view as a field.

  • Thank you. I just tried Twig Tweak and it works great!.. It would be perfect for me. But I need to build a production website that needs to be stable and I see that this module is quite new, having only 312 downloads up to now. Do you know if is it reliable and it will be well maintained?
    – Andrea
    Commented Apr 22, 2016 at 9:28
  • @Andrea I think it is reliable as so far 0 bug reports. It's very new unknown module, but I am sure the number of people using it will go up as people discover it.
    – No Sssweat
    Commented Apr 22, 2016 at 9:32
  • 2
    Only the module developer knows that really @Andrea, the rest of us can only speculate or give an opinion based on experience. The release is marked stable and it's (allegedly) actively maintained. That's as much info as we can give here, but you might be able to get better assurances if you open a "Is this production ready?" issue in the module's queue
    – Clive
    Commented Apr 22, 2016 at 9:32

I help maintain the D8 branch of EVA, which is functionally similar to Twig Tweak's drupal_view() but works as a View display that attaches itself to specified entity bundles as an extra field. This means the View may be reordered within the entity Manage Display UI or e.g., dropped in a field group. Like Twig Tweak's function, it allows contextual filters to be passed as arguments.

The use case for EVA and for the Twig Tweaks solution differs from that for using an entity reference with viewsreference because the latter allows content editors to select different Views on each entity. EVA and drupal_view() inject the same View on every entity (although contextual arguments may change the View results).

If you're creating a bespoke theme there may not be any advantage to EVA vs. twig block injection, but if you want to allow sitebuilders to manage a View as if it were an entity field and configure where it appears using the UI, have a look.


There's now also a project called viewsreference, which allows you to embed whole views into nodes via a field (think entity reference, but for complete views): https://www.drupal.org/project/viewsreference

  • This module also gives the ability to configure options for the view, such as displaying the title and passing view arguments.
    – joekers
    Commented May 20, 2017 at 14:40

I just used hook_entity_extra_field_info() and views_embed_view() for the content of the extra field.

 * Implements hook_entity_extra_field_info().
function MY_MODULE_entity_extra_field_info() {
  $extra['node']['MY_CONTENT_TYPE'] = [
    'display' => [
      'MY_EXTRA_FIELD_NAME' => [
        'label' => 'My Extra Field',
        'description' => '',
        'weight' => 10,

  return $extra;

 * Implements hook_ENTITY_TYPE_view() for node.
function MY_MODULE_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  if ($node->bundle() === 'MY_CONTENT_TYPE') {
    $build['MY_EXTRA_FIELD_NAME'] = [
      '#type' => 'container',
      'label' => ['#markup' => '<div class="label">My Extra Field:</div>'],
      // At the following line embedding the view, 
      // and giving it an optional contextual filter $node->id()
      'view' => views_embed_view('VIEW_NAME', 'DISPLAY_ID', $node->id()),

You can use https://www.drupal.org/project/views_entity_embed. It allows you to embed views in textarea using WYSIWYG editor.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.