Skip to main content
  • Guides & Documentation

Knowledgebase

Featured articles, how-to guides and quick tips.

Getting Node Author's User Fields in a node.html.twig template

You may need to print field values for the node author in your node.html.twig file in Drupal 8. One common use case is to display details about the author of the node/article, such as their name, profile picture and a short bio snippet.

It's fairly easy to do directly within your node.html.twig file, and doesn't require anything more than a few lines of code.

Directly within your node.html.twig file, you can use the following syntax to print the name of the node author:

{{ author_name }}

To print the author's profile picture, you'll have to define the image path as the src value for an img tag, like so:

<img src="{{ file_url(node.Owner.user_picture.0.entity.uri.value) }}" alt=""/>

If you're using custom fields on user profiles in Drupal, and you wish to print the value of such a field, you can use the following syntax, simply switching out "field_custom" for the machine name of your custom profile field:

{{ node.Owner.field_custom.value }}

Save the file and clear the Drupal caches, and you should be good to go!