Send base URL for my custom block In my Drupal 8 site, I am developing a custom block in my module custom, with some text and some images. I created a template, and everything works fine. Now I need to add some images for my custom block, and I don't know how to pass the base URL to call those images. 

In Drupal 7 I used the following code.

function bloques_block_view($delta = '') {
    $block = array();

    $ruta = $GLOBALS['base_url'] . '/' . drupal_get_path("module", "mymodule");
    $link = $GLOBALS['base_url'] ;   

  switch ($delta) {

//footer
    case 'footer':
      $block['subject'] = '';
      $block['content'] = leer_template('footer.tpl', array('%ruta%' =&gt; $ruta, '%link%' =&gt; $link));
      break;
  }
  return $block;
}


Everything works well, but in Drupal 8 it is a little different. The problem comes with build().

    public function build() {
    $ruta = 'holamundo',        
    return array(
        '#theme' =&gt; 'mymodule',
        '#title' =&gt; 'my title ',
        '#ruta' =&gt; '&lt;p&gt;' . $ruta . '&lt;/p&gt;'
    );


}

Just the title works in the template file; $ruta is not working.

  &lt;h2&gt;My Custom Block {{ title }}-{{ ruta }}&lt;/h2&gt;


I don't know if this is the correct way to declare the base URL (just like I did in Drupal 7).

  $ruta = $GLOBALS['base_url'] . '/' . drupal_get_path("module", "bloques");
You can try template_preprocess_block(&amp;$variables). There is a global $base_url variable. Create variable for block template:

function your_module_preprocess_block(&amp;$variables){
  global $base_url;
  $variables['base_url'] = $base_url;

}


Now you can use {{base_url}} in twig template of your block.