How do I print custom user fields? I am trying to customize the authored by information for all of my nodes that prints the User First and Last Name, which are custom fields on the User Profile.  


I copied the node.html.twig template into my theme
I added the following code to load the user information in my preprocess function  

function blend_preprocess_node(&amp;$variables) {

// Load the current user.
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()-&gt;id());

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

// some default getters include
$email = $user-&gt;get('mail')-&gt;value;
$name = $user-&gt;get('name')-&gt;value;
$uid= $user-&gt;get('uid')-&gt;value;

}

I added this code to node.html.twig



{{ title_prefix }}   {% if not page %}
&lt;h2{{ title_attributes }}&gt;
  &lt;a href="{{ url }}" rel="bookmark"&gt;{{ label }}&lt;/a&gt;
&lt;/h2&gt;   {% endif %}   {{ title_suffix }}

{% if display_submitted %}

&lt;div class="posted"&gt;

    &lt;div class="services-icon"&gt;
      {{ content.field_services }}
    &lt;/div&gt; 


  {{ author_picture }}

  &lt;div{{ author_attributes }}&gt;
    {% trans %}Submitted by {{ firstname }} {{ lastname }} on {{ date|date("m/d/Y") }}{% endtrans %}
    {{ metadata }}
  &lt;/div&gt;
&lt;/div&gt;   {% endif %}
{# We hide the comments and links now so that we can render them later. #}   &lt;div{{ content_attributes }}&gt;
{{ content|without('comment', 'links', 'field_tags', 'field_services') }}   &lt;/div&gt;

{% if content.field_tags|length and not is_front %}
{{ content.field_tags }}   {% endif %}
{{ content.links }}   {{ content.comment }} &lt;/article&gt;



How do I make variables (mostly fields) from different entities available to print in different template files?
Assuming this information is from the user profile.

You could do the following

blend.theme

function blend_preprocess_node(&amp;$variables){
    $node = $variables['node'];
    $variables['firstname'] = $node-&gt;getOwner()-&gt;field_first_name-&gt;value;
    $variables['lastname'] = $node-&gt;getOwner()-&gt;field_last_name-&gt;value;
}


From there you can use {{ firstname }} and {{lastname}} anywhere in your template.