Drupal 8: Read field value from $variables in preprocess_html I've been wrestling with Drupal 8 for some time now and have run into a little problem.

I want to get a field value from a content type that I can use in my html--front.html.twig.
I can create a new variable that I can use in the twig template i.e

$variables['custom_twig_variable'] = 'Some important value';

Then in my twig template I would simply call this like this

{{ custom_twig_variable }}

The thing here is that I don't now how to "reach" my field value in the array $variables that is passed into the preprocess_html function.

Array (
  [user] =&gt; Drupal\Core\Session\AccountProxy Object (
    [requestStack:protected] =&gt; Symfony\Component\HttpFoundation\RequestStack Object (
      [requests:Symfony\Component\HttpFoundation\RequestStack:private] =&gt; Array (
        [0] =&gt; Symfony\Component\HttpFoundation\Request Object (
          [attributes] =&gt; Symfony\Component\HttpFoundation\ParameterBag Object (
            [parameters:protected] =&gt; Array (
              [_system_path] =&gt; node/4
              [_controller] =&gt; \Drupal\node\Controller\NodeViewController::view
              [_title_callback] =&gt; \Drupal\node\Controller\NodeViewController::title
              [node] =&gt; Drupal\node\Entity\Node Object (
                [values:protected] =&gt; Array (
                  [vid] =&gt; Array (
                      [x-default] =&gt; 4
                  )
                  [field_background_color] =&gt; Array (
                    [x-default] =&gt; Array (
                      [0] =&gt; Array (
                        [value] =&gt; ff00ff
                      )
                    )
                  )
                )
              )
            )
          )
        )
      )
    )
  )
)


How do I read the value of field_background_color?
So your field is on the node?

Then you need to get the node object first.

&lt;?php
if (($node = \Drupal::routeMatch()-&gt;getParameter('node')) &amp;&amp; $node instanceof \Drupal\node\NodeInterface) {

}


Once you have that, you can read your field, assuming it is a text field, like this: $node-&gt;field_background_color-&gt;value. Make sure to always check if you really have a $node object as done in the snippet above when you're in the global context. You will only have on on node/N, but not on other pages.

There are many questions already about how to access field values, and there are great presentations as well.