title: Drupal 9 - Message and message statut system blocks are not displayed
body: <p>Thanks for taking the time to read my question.</p>
  <p>I have a problem adding the message and message status blocks in my content region using Drupal 9. I'm using a custom theme.</p>
  <p>The blocks are simply not displayed. They are not even added to the DOM.</p>
  <p>Here is my block configuration : <a href="https://imgur.com/gPvEq1Q" rel="nofollow noreferrer">https://imgur.com/gPvEq1Q</a> (Sorry, it's in French. The two blocks are underlined in red)</p>
  <p>And the configuration of each block : <a href="https://imgur.com/q3cBToL" rel="nofollow noreferrer">https://imgur.com/q3cBToL</a> and <a href="https://imgur.com/hePdhHn" rel="nofollow noreferrer">https://imgur.com/hePdhHn</a> (again, in French, but there are no restriction on page, role or type of content - it should appear everywhere)</p>
  <p>I found these solutions online :</p>
  <p>1 - <a href="https://www.drupal.org/forum/support/theme-development/2016-03-08/d8-any-reason-why-blocks-arent-renderingdisplaying" rel="nofollow noreferrer">https://www.drupal.org/forum/support/theme-development/2016-03-08/d8-any-reason-why-blocks-arent-renderingdisplaying</a></p>
  <p>I tried uninstalling my theme, clearing the cache, reinstalling my theme but it doesn't work. The blocks did not appear in the Bartik theme either.</p>
  <p>2 - <a href="https://www.drupal.org/forum/support/post-installation/2018-09-23/new-blocks-not-displaying" rel="nofollow noreferrer">https://www.drupal.org/forum/support/post-installation/2018-09-23/new-blocks-not-displaying</a></p>
  <p>I tried adding a simple test block, it appears normally.</p>
  <p>I tried displaying a test message using $this-&gt;messenger()-&gt;addMessage(&quot;test&quot;); in a module to be sure there was something to display but with no success.</p>
  <p>I'm not sure if it helps but here is my page.twig template :</p>
  <pre><code>&lt;header aria-label=&quot;Site header&quot; class=&quot;header&quot; id=&quot;header&quot; role=&quot;banner&quot;&gt;
      &lt;div id='header-content'&gt;
          &lt;div id=&quot;header-left&quot;&gt;
              {{ page.branding }}
              {{ page.navigation }}
          &lt;/div&gt;
          &lt;div id='header-right'&gt;
              {{ page.user_menu }}
              {{ page.search }}
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/header&gt;
  &lt;section class=&quot;main&quot; id=&quot;main&quot;&gt;
     &lt;main aria-label=&quot;Site main content&quot; class=&quot;content&quot; id=&quot;content&quot; role=&quot;main&quot;&gt;
       {{ page.content }}
     &lt;/main&gt;
  &lt;/section&gt;
  &lt;footer aria-label=&quot;Site footer&quot; class=&quot;footer&quot; id=&quot;footer&quot; role=&quot;contentinfo&quot;&gt;
     &lt;div class=&quot;footer--top&quot;&gt;
       {{ page.footer_first }}
     &lt;/div&gt;
     &lt;div class=&quot;footer--bottom&quot;&gt;
         {{ page.footer_bottom }}
     &lt;/div&gt;
  &lt;/footer&gt;
  </code></pre>
  <p>Does any of you already encountered the problem ? Is there a solution ?</p>
  <p>Thanks again !</p>
  <p><strong>EDIT</strong></p>
  <p>Here is the output from twig debug :</p>
  <pre><code>&lt;!-- THEME DEBUG --&gt;
  &lt;!-- THEME HOOK: 'block' --&gt;
  &lt;!-- FILE NAME SUGGESTIONS:
     * block--messages.html.twig
     x block--system-messages-block.html.twig
     * block--system.html.twig
     * block.html.twig
  --&gt;
  &lt;!-- BEGIN OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' --&gt;
  &lt;div data-drupal-messages-fallback class=&quot;hidden&quot;&gt;&lt;/div&gt;&lt;span data-big-pipe-placeholder-id=&quot;callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&amp;amp;args%5B0%5D&amp;amp;token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA&quot;&gt;&lt;/span&gt;
  
  &lt;!-- END OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' --&gt;
  </code></pre>
  <p>This suggests that the \Drupal::messenger()-&gt;addMessage(); does not output any message.</p>
  <p>A strange thing I noticed testing with a FormBase class is that the Drupal\Core\Form\FormStateInterface::setErrorByName() method is working fine. A message is being displayed and the twig debug output becomes</p>
  <pre><code>&lt;!-- THEME DEBUG --&gt;
  &lt;!-- THEME HOOK: 'block' --&gt;
  &lt;!-- FILE NAME SUGGESTIONS:
     * block--cessoc-messages.html.twig
     x block--system-messages-block.html.twig
     * block--system.html.twig
     * block.html.twig
  --&gt;
  &lt;!-- BEGIN OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' --&gt;
  &lt;div data-drupal-messages-fallback class=&quot;hidden&quot;&gt;&lt;/div&gt;
  
  &lt;!-- THEME DEBUG --&gt;
  &lt;!-- THEME HOOK: 'status_messages' --&gt;
  &lt;!-- BEGIN OUTPUT from 'core/modules/system/templates/status-messages.html.twig' --&gt;
  &lt;div data-drupal-messages&gt;
    &lt;div role=&quot;contentinfo&quot; aria-label=&quot;Message d'erreur&quot;&gt;
            &lt;div role=&quot;alert&quot;&gt;
                &lt;h2 class=&quot;visually-hidden&quot;&gt;Message d'erreur&lt;/h2&gt;
                The title must be at least 5 characters long.
                &lt;/div&gt;
        &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!-- END OUTPUT from 'core/modules/system/templates/status-messages.html.twig' --&gt;
  
  
  
  &lt;!-- END OUTPUT from 'core/modules/system/templates/block--system-messages-block.html.twig' --&gt;
  </code></pre>