Send custom user fields to twig template I'm writing my first Drupal 8 theme.

Now for a block I need all some custom fields of the user. So that I can use it in my theme.

I create a theme file with collectionmanager_preprocess_html method.

use Drupal\Core\Session\AccountProxyInterface;
use Drupal\user\Entity\User;

/**
 * Implements hook_preprocess_HOOK() for HTML document templates.
 *
 * Adds body classes if certain regions have content.
 */
function collectionmanager_preprocess_html(&amp;$variables) {
// Load the current user.
$user = User::load(\Drupal::currentUser()-&gt;id());

// get field data from that user
$firstname = $user-&gt;field_first_name-&gt;value;
$lastname = $user-&gt;field_last_name-&gt;value;

$variables['custom_firstname'] = $user-&gt;field_first_name-&gt;value;
$variables['custom_lastname'] = $user-&gt;field_last_name-&gt;value;
}


If I'm correct I can access the variables in twig with {{custom_firstname}}. But it show always a null value. Can someone help me with this? I can't find my issue on this. The variable $firstname and $lastname contains the correct values.
collectionmanager_preprocess_html() prepares variables for html.html.twig template. For page.html.twig the of the function name should be collectionmanager_preprocess_page(). The same pattern should be used for other theme hooks (view, block, field etc).