1

i have added regions in my theme.info file. now i want to add default header and footer with logo in all the pages of my site.This is my page.html.twig

<div class="layout-container">

  <header role="banner">
    {{ page.header }}
  </header>

  {{ page.primary_menu }}
  {{ page.secondary_menu }}

  {{ page.breadcrumb }}

  {{ page.highlighted }}

  {{ page.help }}

  <main role="main">
    <a id="main-content" tabindex="-1"></a>{# link is in html.html.twig #}

    <div class="layout-content">
      {{ page.content }}
    </div>{# /.layout-content #}

    {% if page.sidebar_first %}
      <aside class="layout-sidebar-first" role="complementary">
        {{ page.sidebar_first }}
      </aside>
    {% endif %}

    {% if page.sidebar_second %}
      <aside class="layout-sidebar-second" role="complementary">
        {{ page.sidebar_second }}
      </aside>
    {% endif %}

  </main>

  {% if page.footer %}
    <footer role="contentinfo">
      {{ page.footer }}
    </footer>
  {% endif %}

</div>{# /.layout-container #}

I have placed files region--header.html.twig and region--footer.html.twig .Please help me how to place logos and other contents in header and footer

0

You define a region in your theme's info file and then print it in your page.html.twig. Content to each region is added via blocks. You only add your own region templates when you need to make some changes to the markup.


OK, so you added the regions in your info file, and printed them in your page template, fine. First of all, delete your region--header.html.twig and region--footer.html.twig again. Then in the backend of your site go to Structure > Blocks. Your newly added regions should appear there. Now place some blocks in your newly added regions. Save, flush cache and visit your frontend again. Your regions should be populated now.

And regarding the region--YOURREGION.html.twig templates you should have deleted by now, these only will be picked up when these regions are populated – with blocks. Otherwise these regions simply won't get printed at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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