D8

1. Firstly locate and edit your theme’s .info.yml file

Let’s call our region “My Custom Region” and declare it in our THEMENAME.info.yml file. Each region is declared as a subkey of the regions element as you can see below:

# Region metadata.
regions:
  header: 'Header'
  content: 'Content'
  content_bottom: 'Content (bottom)'
  primary_menu: 'Primary menu'
  banner_top: 'Banner (top)'
  banner_bottom: 'Banner (bottom)'
  footer: 'Footer'
  page_top: 'Page top'
  page_bottom: 'Page bottom'
  my_custom_region: 'My Custom Region'

2. Edit your theme’s page.html.twig file to add the following where it suits you

{% if page.my_custom_region %}
  <section class="layout-custom-region" role="complementary">
    {{ page.my_custom_region }}
  </section>
{% endif %}

When you declare a new region in your theme, you override all the defaults provided by Drupal core, so in most cases you will want to have content, page_bottom, and page_top regions at a minimum because many modules expect them to be there.

Don’t forget to clear the cache.

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *