How DO I store/retrieve data and display them in templates?
One way to achieve this is using preprocess function. In your theme's '.theme' file, write a preprocess function. Example:
In bartik.theme

function bartik_preprocess_html__node__28(&amp;$vars) {

$nids = \Drupal::entityQuery('node')
        -&gt;condition('type','article','=')
        -&gt;condition('status',1,'=')
        -&gt; execute();
$nodes = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;loadMultiple($nids);
foreach ($nodes as $key =&gt; $value) {
$title = $value-&gt;title-&gt;value;

}
$vars['title'] = $title;

}


(node__28 is any node page where you want to see all results, I made this basic page)

Now in html--node--28.html.twig template, retrieve title of content type = article

{{ title }}