Use Arrays in Twig Template from Custom Block I'm attempting to use arrays in a twig template from variables in a custom block.

In my custom block I have 

public function build() {
    $query = \Drupal::entityQuery('node')
        -&gt;condition('type','product')
        -&gt;sort('created', 'DESC');

    $nids = $query-&gt;execute();
    $i = 0;

    foreach ($nids as $nid) {
        $node = NODE::load($nid);
            $imageurl[$i] = $node-&gt;get('field_product_page_display')-&gt;entity-&gt;getFileuri();
            $title[$i] = $node-&gt;get('field_title')-&gt;value;
            $imageurl[$i] = str_replace("public://", "", $imageurl[$i]);
            $i += 1;

        }
    return array(
        '#theme' =&gt; 'product_display',
        '#imageurl' =&gt; $imageurl,
        '#product_title' =&gt; $title,
        );
}


In my mymodule.module file I have 

function mymodule_theme($existing, $type, $theme, $path){
    return array('header' =&gt;
        array(
            'variables' =&gt; array(
                'header_title' =&gt; 'Default Title',
                'header_size' =&gt; 'h1',
                'text_align' =&gt; 'center',
                'uppercase' =&gt; FALSE,
                'grid_size' =&gt; 12,
                ), 
            ),
        'product_display' =&gt; 
            array(
                'variables' =&gt; array(
                    '#imageurl' =&gt; [],
                    '#product_title' =&gt; [],
                    ),
                ),
        );
}


in my product_display.html.twig file I have

{% for product in product_title %}
    {% for image in imageurl %}
         &lt;div class="large-4 medium-3 column"&gt;
            &lt;img src="./sites/default/files/{{ image }}"&gt;
                        &lt;div class="product-title"&gt;
                            {{ product }}
                        &lt;/div&gt;
                    &lt;/div&gt; 
    {% endfor %}
{% endfor %}


I know for sure that my custom block.php file is able to retrieve the data properly because using Debug() on $imageurl or $title displays all the information. However using Dump() in product-display.html.twig shows the #imageurl and #product_title arrays as empty.
There is a syntax error in your hook_theme. Use this instead:

function mymodule_theme($existing, $type, $theme, $path){
return array('header' =&gt;
    array(
        'variables' =&gt; array(
            'header_title' =&gt; 'Default Title',
            'header_size' =&gt; 'h1',
            'text_align' =&gt; 'center',
            'uppercase' =&gt; FALSE,
            'grid_size' =&gt; 12,
            ), 
        ),
    'product_display' =&gt; 
        array(
            'variables' =&gt; array(
                'imageurl' =&gt; [],
                'product_title' =&gt; [],
                ),
            ),
    );


}

The # sign in a render array is used to differenciate a key that has a meaning in the rendering versus an element. It shouldn't be included in the theme definition.