0

I try to get rid of the site name which come with the twig expresseion {{ page.header }}.

To get further details of that variable I enabled twig debug mode and printed it {{ kint(page.header) }}.

It seems that block--system-branding-block.html.twig is used within {{ page.header }}. At the end of file it shows.

{% if site_name %}
   <div class="site-name">
      <a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home">{{ site_name }}</a>
    </div>
{% endif %}

The question is how to use a twig function to remove that item from {{ page.header }}. There is a filter which is called without and I already applied it to page.header|without('site_name'). But that didnt work.

Additional question, how to establish a connection between the printed variables from {{ kint(...) }} and the template file. Iam looking for that specific div which displays the site name but I can't find it in the printed variables from debug in order to remove it.

1 Answer 1

2

You can remove the block in the block layout.

If you don't want to do it in the ui, you have to look for the block name. This is probably sitebranding.

For example to remove the block with the name sitebranding from the region header in the page template:

{{ page.header|without('sitebranding') }}

If you are looking for the site name in the kint print out, it is not always possible to find the actual content early in the templates. Often it is processed at a later stage.

2
  • Thanks, I just want to get it removed on front_page and the without statement plus is_front did the job in the twig template!
    – user39280
    Feb 29, 2016 at 7:50
  • 1
    Normally you would do this in the ui. In the block layout you can configure the visibility to not show the block if the page is <front>.
    – 4uk4
    Feb 29, 2016 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.