0

Good morning all,

Today I would like to ask a simple question about the menus. How do you make a clean sidebar that takes up the entire length of the page? In general, the themes offer only natively horizontal menus that occupy the entire width.

To have a sidebar, you must put the menu in a block side position and make the necessary adjustments with CSS?

1 Answer 1

3

Yes, theme regions and CSS are what you need. Basically, from admin/structure/block you place your menu block into one of your theme's region. And then, with CSS you adjust the style of the region to your needs.

If the HTML structure does not match your needs, you can also alter the page template of your theme (page.html.twig file). If this file does not exist in your theme, just copy it from \core\themes\classy\templates\layout\page.html.twig to themes\yourtheme\templates\optionalsubfolder\page.html.twig). This file allows you to modify the HTML structure of your page and consequently, the position of your page regions within the HTML.

e.g. If I place my Menu Block into "Sidebar first" region, I know that {{ page.sidebar_first }} twig variable is the one that contains the display of the menu.

3
  • 1
    I'd recommend copying templates from your base theme, if you have one, instead of classy.
    – sonfd
    Jul 19, 2021 at 16:10
  • @sonfd I agree. Classy subthemes are relatively advanced. Subtheming Classy does have advantages, such as complete control over theming. It’s a lot more work though, and you need to know what you’re doing. Jul 23, 2021 at 3:00
  • @sonfd, you're right. As a matter of fact, I'd recommend using Twig debugging to spot which template files are being used and may be overriden if necessary.
    – misterdidi
    Jul 27, 2021 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.