While making my new teme with twig I realize tat is ignoring all te proprieties I added in block--system-branding-block.html.twig to the logo img and rendering it from stable/templates/image.html.twig

My custom code is very simple, just adding a class to the img to modify it using css:

{% block content %}
  {% if site_logo %}
    <a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home" >
      <img src="{{ site_logo }}" alt="{{ 'Home'|t }}" class="site-logo"/>
  {% else %}
    <div class="site-name">
      <h1 id="site-name">
        <a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home">{{ site_name }}</a>
  {% endif %}
  {% if site_slogan %}
    <div class="site-slogan">{{ site_slogan }}</div>
  {% endif %}
{% endblock %}

So I should get for logo:

   <a href="<front>" title="Home" rel="home" >
      <img src="mylogo.svg" alt="Home" class="site-logo"/>

And getting instead:

<img src="logo.svg" alt="Inicio" typeof="foaf:Image">

As yo see, no link, no custom class, on theme debug show:
BEGIN OUTPUT from 'core/themes/stable/templates/field/image.html.twig'
just over the logo img and its ends just after, should not read the image.htl.twig and use the block--system-branding-block.html.twig file only for the branding section

Also is ignoring the if and rendering the site-name without any style

Members fund testing for the Drupal project. Drupal Association Learn more


huma2000 created an issue. See original summary.

huma2000’s picture

Issue summary: View changes
huma2000’s picture

Issue summary: View changes
joelpittet’s picture

Issue tags: +Twig


Is it picking up your branding block file at all? Could you post the path that twig debug outputs?

huma2000’s picture

Here is the printout of twig debug:


<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
   * block--alteamorgan-branding.html.twig
   x block--system-branding-block.html.twig
   * block--system.html.twig
   * block.html.twig
<!-- BEGIN OUTPUT from 'themes/alteamorgan/templates/block--system-branding-block.html.twig' -->

<section id="block-alteamorgan-branding" class="contextual-region block-alteamorgan-branding block block-system block-system-branding-block">
    <div data-contextual-id="block:block=alteamorgan_branding:langcode=es"></div>

    <div >

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'image' -->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/field/image.html.twig' -->
<img src="" alt="Inicio" typeof="foaf:Image" />

<!-- END OUTPUT from 'core/themes/stable/templates/field/image.html.twig' -->

Altea MoganLa escritora favorita de Nyarlathotep


<!-- END OUTPUT from 'themes/alteamorgan/templates/block--system-branding-block.html.twig' -->

There you can see that is starting to print my template, then changes to img.html.twig from stable and then says that finish with my template, but ignoring all the markup on it and just printing plain text instead the formatted one.

joelpittet’s picture

I've got a guess. Can you post your page template. Specifically the part of the page the block he's placed into ?

joelpittet’s picture

Version: 8.0.0 » 8.0.x-dev
huma2000’s picture

Here you are (just remove the .txt from them).
I cannot always reproduce it, seems to happen randomly now, dunno why.

Cottser’s picture

Category: Bug report » Support request

(Until proven otherwise)

Jeff Burnz’s picture

Well, basically it looks like the branding vars are being printed in the page template, so is the block even enabled at all? Did you place the branding block in a region?

huma2000’s picture

block is placed in header region, is being rendered, just sometimes from the wrong template.
Sees not to happen now I reinstalled d8 from scratch and copy te theme over... maybe was something wrong on my installation? Was an updated install since the first rc

Jeff Burnz’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Spanners’s picture

I know this has been closed as fixed, but in case this helps someone else.

If you have copied the block--system-branding-block.html.twig from core/theme/Bartick/templates into your custom theme, ensure that the Site Branding block is placed in a region of your page/s.

Turn off the Site Logo and Site Name in the Appearance settings for your custom theme.

Then configure the Site Branding block to display the Site Logo, Site Name or both.

Your changes to the block--system-branding-block.html.twig should be reflected in the Site Branding block.