Region

Regions are the slots a theme offers for blocks. Site builders fill them in the admin, but only the theme's code decides which slots exist and where.

Learn DrupalDrupal glossary

A region is a named area of a Drupal theme's page, such as Header, Content or Footer. The theme declares its regions under the regions key of its .info.yml file and prints each one in a template as page.machine_name. A block is placed into exactly one region, and the theme decides where that region appears.

How regions work in Drupal 11

A region has a machine name and a label. In Twig the machine name becomes a variable on the page: a region named header is printed as {{ page.header }} in page.html.twig. The core template prints some regions always and wraps others, such as the sidebars and the footer, in a condition, so an empty one leaves no markup.

A theme that declares no regions gets twelve defaults from ThemeExtensionList: sidebar_first, sidebar_second, content, header, primary_menu, secondary_menu, footer, highlighted, help, page_top, page_bottom and breadcrumb. Declare even one region and these defaults no longer apply. The Drupal User Guide says only the Content region is required.

The regions_hidden key hides regions from the block interface, and the System module adds page_top and page_bottom to it for every theme. The Block layout page lists only visible regions.

How a theme region is declared, filled and printedOlivero declares its regions in olivero.info.yml, for example header with the label Header, content with Content, and footer_bottom with Footer Bottom. On the Block layout page blocks are placed in them; Olivero's defaults put Site branding in Header, Main page content in Content and Powered by Drupal in Footer Bottom. The page.html.twig template prints each region as page.header, page.content and page.footer_bottom.1. olivero.info.yml declares the regionsheader: Headercontent: Contentfooter_bottom: Footer Bottom2. Blocks placed in them on Block layout (Olivero's defaults)Site brandingMain page contentPowered by Drupal3. page.html.twig prints each region where it should appear{{ page.header }}{{ page.content }}{{ page.footer_bottom }}Olivero declares 13 regions; three are shown here.
Olivero declares its regions in olivero.info.yml, Block layout places blocks in them, and page.html.twig prints each one.

Example

Olivero declares thirteen regions, among them Header, Primary menu, Hero (full width), Breadcrumb, Content Above, Content, Sidebar, Content Below, Footer Top and Footer Bottom. A small custom theme might declare these:

regions:
          header: Header
          content: Content
          footer: Footer
          page_top: Page top
          page_bottom: Page bottom

Its page.html.twig then needs {{ page.header }}, {{ page.content }} and {{ page.footer }} where each area should appear.

Common mistakes

  • Declaring one region and losing the rest. Blocks that sat in the vanished regions are not rendered, and a cache rebuild disables them.
  • Dropping page_top and page_bottom. The Drupal.org guide says to keep them and not to remove them from html.html.twig. The System module reserves them for modules to fill.
  • Declaring a region but not printing it. The template must output page.machine_name or the blocks placed there do not appear on the page.

For marketing and content teams

Regions are the slots your design offers, and you cannot add one from the admin screens, because they are declared in the theme's code. Moving a block between existing regions is a task for Structure › Block layout; the block layout page also orders blocks inside a region by weight. If a campaign needs a new slot, such as a banner above the header, ask your developer to add a region to the theme.

With DXPR

DXPR Theme declares its own regions, for example Hero Region, Content Top and Content Bottom, so its Block layout page differs from Olivero's. DXPR Builder can also place a Drupal block as an element inside the page body, so a block does not always need a theme region. See DXPR Builder and DXPR Theme.

Sources

Questions about Region

Open Structure › Block layout and choose the theme's tab. Each visible region is a heading with a Place block button. The Demonstrate block regions link shows the region names on a sample page. The full list is the regions key in the theme's info file.

A placed block has exactly one region. To show the same block in a second region, place it again. The Drupal User Guide says each copy of a block has its own configuration and visibility rules.

Blocks assigned to a region the theme no longer declares are not rendered. When caches are rebuilt, Drupal disables them, moves them to the theme's default region and shows a warning for each enabled block.

The System module hides page_top and page_bottom from the block interface because they are reserved for modules to fill from outside the block system. The theme still prints them in html.html.twig.

Related terms

All Drupal terms from A to Z