Drupal 8: How to Embed a View Block

Drupal 8 has a built-in tool that allows site builders to generate lists of content. Unlike WordPress or Drupal 7, this feature comes with core, so it’s crazy easy to create lists of all types — with images, links, just about anything that can be added on the page. With the addition of two additional modules and appropriate configuration, an editor can embed just about any list on any page.

What do you need:

  • Drupal 8 core with Views enabled.
  • A View that creates a list that you’d like embed on another page. Example: A list of the four most recent news article to display on the homepage.
  • Paragraphs module, which allows the editor to build complex pages with different types of structured content. Paragraphs are basically page sections.
  • Views Reference Field module, which is used to create a field that can reference then properly display a View block inside a Paragraph.
  • A custom Paragraph type with a Views Reference Field set up to reference View blocks.

Note that Drupal core has the ability to add a field that references Views configuration, but that does not output the list itself, just a label or the name of the View. That’s why the Views Reference Field module is needed.

Steps:

First create a Paragraph type. Then add a new Field with the field type Reference > Views Reference:


In the field configuration, you can limit that available displays. I prefer to select Block, as this typically gets the best options. The other display types may behave unexpectedly when output as page content.

Save the field, and continue with other Paragraph configuration. If you create a custom Paragraph type just for lists, be sure to include that paragraph type in the Paragraph reference field in the content types.

To use, create or edit the page, then add a Paragraph and select the View on the field.