Search code examples
drupaldrupal-themingdrupal-8

Drupal 8 site_name variable is null


Im trying to access this variable but I'm getting a null value, {{ site_name }} page.html.twig

Drupal suggest that I check the theme settings and enable this display.

 * - site_name: The name of the site. This is empty when displaying the site
 *   name has been disabled in the theme settings.

However when I check my themes settings I don't see anything useful http://puu.sh/lOqTY/97a7a12ae8.png

I also checked the global settings, http://puu.sh/lOr0S/0ed321e23e.png


Solution

  • In my case I was calling site_name variable from the twig template of Site branding block. I was also suffering for site_name was an empty string.

    Than I found Site Branding block settings at Administration > Structure Block > layout > Site Branding. There you will see "Toggle branding elements" tab which allows you to show / hide the site name, logo and site slogan.

    Check if you have Site name marked to be shown. Than save block settings and clear the cache. site_name should now work.