I want a variable in menu.html.twig file. I tried adding the following hook in the theme's .theme file, but the template file doesn't print anything.
function my_theme_name_preprocess_menu(&$variables) {
$account = \Drupal::currentUser();
$variables['current_username'] = $account->getDisplayName();
}
The menu.html.twig template file contains the following markup.
<div class="title-container">
<span class="item-title">{{ current_username }}</span>
</div>