Change the site slogan on certain pages I have a Drupal 8 site with a content type called Landing Page.  I'm using the bootstrap theme and I have the block showing the brand info (including site slogan) in the navbar.

I want some of the landing pages to have a different site slogan (shown in the navbar).  How can I do that?

What I tried

I thought of adding a text field custom site slogan to my Landing Page content type and then using a twig template (content type node template) to show the slogan, but the slogan is printed in the header, and the template comes after that.

I could also make a different branding block for each page I need to change the slogan on and manually change the text in a twig template, but that seems like a very horrible, labor intensive way to do it.
Ok, thanks to the hint from @Hudri, here's what I did.

In mycustomtheme.theme:

function MYCUSTOMTHEME_preprocess_block(&amp;$vars) {
  if ($vars['configuration']['id'] === 'MYMODULE_site_branding_nolinks_block') {
    $site_config = \Drupal::config('system.site');
    $vars['site_slogan'] = $site_config-&gt;get('slogan');
    $vars['site_name'] = $site_config-&gt;get('name');
    $node = \Drupal::routeMatch()-&gt;getParameter('node');
    if ($node instanceof \Drupal\node\NodeInterface) {
      $type = $node-&gt;getType();
      // For landing pages, set the site slogan to the value of the slogan field.
      if ($type === 'landingpage') {
        $node = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load($node-&gt;id());
        $slogan_field = $node-&gt;get('field_slogan')-&gt;getValue();
        $slogan_field = $slogan_field[0]['value'];
        $vars['site_slogan'] = $slogan_field;
      }
    }
  }
}


But, we're not done yet, because the block (provided by my custom module) is cached the same for every page; it needs to be cached per URL, since it might be different for each landing page.

To fix that, in mymodule/src/Plugins/Blocks/myBlock.php, add this code:

  // Caching must be added here:
  // https://drupal.stackexchange.com/questions/223376/what-is-the-correct-way-to-set-cache-contexts-on-custom-blocks
  public function getCacheContexts() {
    return Cache::mergeContexts(parent::getCacheContexts(), ['url.path', 'url.query_args']);
  }