How to build render array with node title linked to node for a list of nodes I have a paragraph type to output a list of content. The editor can set different options, one of them is to show the list as teasers or just node titles linked to node. The corresponding part in code looks like:

    if ($teaser_display) {
      $value = \Drupal::entityTypeManager()-&gt;getViewBuilder('node')-&gt;view($node, 'teaser');
    }
    else {
      $value = \Drupal::entityTypeManager()-&gt;getViewBuilder('node')-&gt;viewField($node-&gt;get('title'), ['link' =&gt; true, 'type' =&gt; 'entity_reference_label']);
    }


Is there a way to build the render array for titel field linked to the node without creating a dedicated view mode and without rendering the markup directly? I thought it should somehow work to use the method viewField() as $display_options can either be a view mode or an array with display options.
As pointed out by @4k4 I used the entity reference field formatter, which does not apply here. Theming as link, as answered in How do I theme a link? does the job:

if ($teaser_display) {
  $value = \Drupal::entityTypeManager()-&gt;getViewBuilder('node')-&gt;view($node, 'teaser');
}
else {
  $value = [
    '#type' =&gt; 'link',
    '#title' =&gt; $node-&gt;label(),
    '#url' =&gt; $node-&gt;toUrl(),
    '#cache' =&gt; ['tags' =&gt; $node-&gt;getCacheTags()],
  ];
}