How to Create a Menu Block in Drupal 8

How to Create a Menu Block in Drupal 8
An OSTraining member asked us how to display a menu with more than one level in Drupal.

In Drupal 7, you could do this by using the Menu block module or by using a theme that had added support for more complex menus.

However, in Drupal 8, the Menu block module has been moved to the core. Here’s how it works …

  • In Drupal 8, go to Structure > Block layout.
  • Select “Place block”.
  • Scroll down till you find “Main Navigation” or the menu you want to use and select “Place block”.
Placing the block in Block layouts

Here you can decide if you want the title of the block to be on display and set the visability options for the block.

Note that you must choose which content types this will be displayed on if you do not tick any of these content types the menu will not appear.

  • Select “Menu Levels” and choose the level of menu you want to be displayed on this site.
Configuring the block

Now you should see the menu displayed in the sidebar region of your Drupal site on all of your basic pages.

side-menu

Author

0 0 votes
Article Rating
Subscribe
Notify of
4 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Artem Shymko
Artem Shymko
7 years ago

Major feature Menu Blocks has is setting up a Parent item for a menu block, where show above example doesn’t have it. Any insights of how this can be approached in D8?

ASHISH MAHAJAN
ASHISH MAHAJAN
6 years ago

hi there, i have one scenario where i need to filter menus on the basis of drop down selection. Foe ex. i have 5 menus menu1, menu2, menu3, menu4, menu5 and one dropdown with value IT and HR. the menu 4 will be changed according the dropdown value, if i select IT then menu 4 should be changed to IT similar for HR and if none select menu 4 will be dispalyed. Is it possible?

steve
steve
6 years ago
Reply to  ASHISH MAHAJAN

Hi Ashish,
You can assign specific menus to pages by restricting the pages it appears on.

Mindhunter
Mindhunter
5 years ago

The only problem is when there are no secundary links, the menublock is still rendered. So the sidebar region is showing but empty. Does anyone know how to not render the sidebar if there are no links in the menublock?

4
0
Would love your thoughts, please comment.x
()
x