Render Array Customise Theming I have what is probably a common question ... How do render arrays get parsed into the the twig template - If we have a controller class which outputs a render array, such as:

$output['element1']=array ("#type"=&gt;"markup","#markup"=&gt;"Hello World!");
$output['element2']=array ("#type"=&gt;"markup","#markup"=&gt;"Today is a nice day!");


Now, lets say that we're using the bootstrap framework, hence using row and columns for layout, if we want the array elements to be output in the following manner:

&lt;div class="row"&gt;
    &lt;div class="col-md-12"&gt;
    Hello World!
    &lt;/div&gt;
&lt;/div&gt;
&lt;div class="row"&gt;
    &lt;div class="col-md-12"&gt;
    Today is a nice day!
    &lt;/div&gt;
&lt;/div&gt;    


How can this be done?  It is clear that Drupal will initially use the page.html.twig template, which will call the region.html.twig template, which in turn will call the block.html.twig template in order to display the render array.  But, the block.html.twig will output the render array as:

 Hello World! Today is a nice day!


Namely,it will not output the div tags - mostly because the block.html.twig doesn't know about them.  And looking at the block.html.twig it appears that the output is only available as 'content':

 {{ content}}


And there is no way of templating the content in the following way:

 &lt;div class="row"&gt;
     &lt;div class="col-md-12"&gt;
        {{ content['element1'] }}
     &lt;/div&gt;
 &lt;/div&gt;
 &lt;div class="row"&gt;
     &lt;div class="col-md-12"&gt;
        {{ content['element2'] }}
     &lt;/div&gt;
 &lt;/div&gt;


Secondary related query:

What would also be useful, is being able to ascertain which class called the page.html.twig so that one could use the {% if calling_page="page name" %} in the block.html.twig template

Hopefully, you get what I am outining here.  Thanks in advance and please operate upon the premise I'm totally new to Drupal when outlining solutions.
I can answer the first part of your question... 

Drupal uses render arrays for the different outputs. Since you only specify two single dimension arrays with #markup they are rendered as 2 strings.

There are multiple ways to achieve what you want, I will highlight 2;


Use #prefix and #suffix:

$output['element1']=array (
  "#type"=&gt;"markup",
  "#markup"=&gt;"Hello World!"
  "#prefix"=&gt;'&lt;div class="row"&gt;&lt;div class="col-md-12"&gt;',
  "#suffix"=&gt;'&lt;/div&gt;&lt;/div&gt;',
);

Use nested elements:

$output['element1']=array (
  'row' =&gt; array(
    '#prefix' =&gt; '&lt;div class="row"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    'cols' =&gt; array( // This has no #, so is the next level of elements
      '#markup' =&gt; t('Hello World!'),
      '#prefix' =&gt; '&lt;div class="col-md-12"&gt;',
      '#suffix' =&gt; '&lt;/div&gt;',
    ),
  ),
);



See this related issue: How to nest elements in a render array.

However, there might be cases where it is not possible to alter the output of modules. Instead you want to do this in the theme. Your suggestion was not that bad. It is just that in twig arrays are noted with a dot symbol. {{ content['element1'] }} should be {{ content.element1 }}

&lt;div class="row"&gt;
     &lt;div class="col-md-12"&gt;
        {{ content.element1 }}
     &lt;/div&gt;
 &lt;/div&gt;
 &lt;div class="row"&gt;
     &lt;div class="col-md-12"&gt;
        {{ content.element2 }}
     &lt;/div&gt;
 &lt;/div&gt;