Implementing responsive sidebars

So far, we have only been dealing with a one column layout. All of our blocks have been assigned to regions before, after, or within our main content. Now we are faced with our first block that is associated with a sidebar. The challenge is to make sure that when content is added to a sidebar, our main content region adjusts accordingly.

For this next section, we will be modifying our page.html.twig template to conditionally look for the existence of sidebars and alter the column classes of our content region.

Begin by opening page.html.twig and adding the logic and markup for the sidebar first region. This markup will be added directly below the <div class="row"> section, but above the content wrapper:

New markup ...

Get Drupal 8: Enterprise Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.