Custom pseudo field not rendered when no other field has content Usecase: I want to have a title field in view mode administration to be able to place it between some other fields. This field has different content depending on node type, view mode and some other fields which is handled by a custom function.

Solution so far:

 /**
 * Implements hook_entity_extra_field_info().
 */
function mymodule_entity_extra_field_info() {
  $extra = array();

  foreach (NodeType::loadMultiple() as $bundle) {
    $extra['node'][$bundle-&gt;Id()]['display']['mymdoule_title'] = array(
      'label' =&gt; t('Extra title'),
      'description' =&gt; t('Display the title of the node e.g. in teaser'),
      'weight' =&gt; 100,
      'visible' =&gt; TRUE,
    );
  }

  return $extra;
}


And then

/**
 * Implements hook_ENTITY_TYPE_view for nodes
 *
 *  - render our pseudo fields
 */
function mymodule_node_view(array &amp;$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {

  // if our pseudo field is used we use our costum class to build the render array
  if ($display-&gt;getComponent('mymodule_title')) {
    $nodeCustomisation = new NodeCustomisation($entity);
    $nodeCustomisation-&gt;titleExtraField($build, $view_mode);
  }
}


It is working as I can see my pseudo field when I go to the view mode administration page of any content type. I can place the field somewhere and it is rendered.

Problem:
As soon as the pseudo field is the only field with content when viewing a node in this view mode nothing is rendered but the node wrapping &lt;article&gt;-tag from node.html.twig. The array {{ content }} in this twig template is empty although the pseudo field should have content for sure - when I add a node field to the view mode which has content I see my pseudo field again.
So I found my fault - when you describe a field the render array needs to have an array of field items. So the $build-array needs to look like this:

$build['igb_title'][] = array(
      '#type' =&gt; 'html_tag',
      '#tag' =&gt; 'h2,
      '#value' =&gt; $entity-&gt;label()
    );


In field_group_remove_empty_display_groups it is checked if a field as at least one item:

$has_items = isset($element[$name][0]);


If $has_items is false the field group is emptied if there is no other field with a value. I think I might need to go deeper into this render array thing...

Best,
Tobias