By default, if you haven’t specified any regions (which we haven’t yet) Drupal will give you all the default in-built regions. To see them all go to Structure > Block Layout.
If you want to keep things simple, as I do, you can provide Drupal with a list of the regions you want to use. Drupal will not create the rest so it will be tidier and more useable for someone using your theme. You can also rename them at the same time and decide their order.
In your .info.yml file you need to add something like this:
regions:
secondary_menu: 'Top Menu'
header: Header
primary_menu: 'Main Menu'
breadcrumb: Breadcrumb
s
content: 'Main Content
'
sidebar_first: 'Sidebar'
footer: Footer
Once again, indents must be two spaces and not tabs. The whole file should now look like this:
name: Your Theme
type: theme
description: 'A very simple theme for a simple but attractive responsive Drupal website'
core_version_requirement: ^8 || ^9
base theme: false
libraries:
- yourtheme/global-styling
regions:
secondary_menu: 'Top Menu'
header: Header
primary_menu: 'Main Menu'
breadcrumb: Breadcrumbs
content: 'Main Content'
sidebar_first: 'Sidebar'
footer: Footer
Remember to change “Your Theme” and “yourtheme”. Upload this edited .info.yml file to your server and clear Drupal’s cache. You may get a message that some blocks have been disabled. If you want them you can always put them back later.
If you visit the Structure > Block Layout page you should see it lists the regions you have chosen, by the names you have given them.
Now you need to place the blocks you want to use in the regions that you have set up for them. This is how I have set up mine for now. I removed some blocks. You can always add them back later.
I also configured the Breadcrumbs block so that it doesn’t appear on the Home (Front) page. By default it doesn’t but I like to do it anyway. I did the same for all blocks in the sidebar as we are not going to have a sidebar on the Home page.
There is a problem though. I you clear your cache and then view your site, the regions may not be in the order they are in on the Block Layout page. That’s where templates come in.
Leave a Reply