Drupal’s theme system allows a theme to have nearly complete control over the appearance of the site, which includes both the markup and the CSS used to style the markup. For this system to work, modules, instead of writing HTML markup directly, need to return “render arrays”, which are structured hierarchical arrays that include the data to be rendered into HTML (or XML or another output format), and options that affect the markup. Render arrays are ultimately rendered into HTML or other output formats by recursive calls to drupal_render(), traversing the depth of the render array hierarchy. At each level, the theme system is invoked to do the actual rendering.

function THEME_preprocess_page(&$variables) {

// Load block(shoppingcart).
$block = \Drupal\block\Entity\Block::load('shoppingcart');
$variables['cart_output'] = \Drupal::entityTypeManager()
  //Get main_menu block title
    $block = \Drupal\block\Entity\Block::load('main_menu')->label();

 $variables['youblockname'] = $block;