Determine which region a menu block is rendered in I need to re-use the same menu in two different regions, with slightly different markup. My thought was to simply check which region the block was being rendered in, and use if statements to modify the classes/structure as needed.

I've hit a roadblock; I was able to find a way to get what region a block is in, but I can't figure out how to pass that data to the menu. Here's my current code:

// Add a region variable to a block.
function theme_preprocess_block(&amp;$variables, $hook) {
    $block_id = $variables["elements"]["#id"];
    $block = \Drupal\block\Entity\Block::load($block_id);
    $variables["region"] = $block-&gt;getRegion();
}


I can output the region variable just fine in block--system-menu-block.html.twig, but trying the variable doesn't get passed to menu.html.twig, which is where I need it. 

I feel like I'm a stones through form an answer for this, if someone could point me in the right direction I'd be greatly appreciative.

Quick side note: I'm very new to Drupal, coming from WordPress development. So far it's been a difficult transition, so please assume I know nothing about themeing :)
Figured this out with the help of an article!

http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion

// Add a region variable to a block.
// http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
function THEMENAME_preprocess_block(&amp;$variables) {
    if (isset($variables["elements"]["#id"])) {
        $block_id = $variables["elements"]["#id"];
        $block = \Drupal\block\Entity\Block::load($block_id);

        if ($block) {
            $variables["content"]["#attributes"]["region"] = $block-&gt;getRegion();
        }
    }
}

// add a template suggestion based on region name
// http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
function THEMENAME_theme_suggestions_menu_alter(array &amp;$suggestions, array $variables) {
    if (isset($variables["attributes"]["region"])) {
        $suggestions[] = $variables["theme_hook_original"] . "__" . $variables["attributes"]["region"];
    }
}


That doesn't do exactly what I was trying for, but it does let me use different templates based on which region a block is being rendered in. Close enough for me :)