How can I render more than one field value in the controller? in my case i have a controller that it send for me the title , to the view , but i want to send the tittle and the body of the article both , i have tried to send them from the controller but it doesn't work for me
how can i send them both from the controller (title and body) ?

here is tmy controller

 public function myPage() {
    $data = \Drupal::service('myservice.ran');
    $dataService = $data-&gt;getArticles();
    return $this-&gt;renderMyPage($dataService);
  }
  function renderMyPage($articleObjects) {
    $articles = [];
    foreach ($articleObjects as $article) {
      $articles[] = [
        '#type' =&gt; 'html_tag',
        '#html_tag' =&gt; 'h2',
        '#value' =&gt; [$article-&gt;title-&gt;value,$article-&gt;body-&gt;value],
        '#cache' =&gt; [
          'tags' =&gt; $article-&gt;getCacheTags(),
        ],
      ];
    }
    return $articles;
  }
What I suggest is the this solution, create a custom template, for your page, in controller pass the data to the twig template.
public function myPage() {

    $data = \Drupal::service('myservice.ran');
    $dataService = $data-&gt;getArticles();
    $articles = [];
    foreach ($dataService as $article) {
      $articles[] = [
        'title' =&gt; $article-&gt;title-&gt;value,
        'body' =&gt; $article-&gt;body-&gt;value,
      ];
    }
    $build = [
      '#theme' =&gt; 'my_template',
      '#data' =&gt; [
        'articles' =&gt; $articles,
        'whatelse' =&gt; &quot;what esle I want&quot;
      ],
      '#cache' =&gt; ['max-age' =&gt; 0],
    ];
    $output = \Drupal::service('renderer')-&gt;renderRoot($build);
    $response = new Response();
    $response-&gt;setContent($output);
    return $response;
  }

then all the data will be available on data in your custom twig template. ( you can change its name to whatever you want).
just be sure you clear the cache when you create your custom template.
A helper article