I added for users a couple of fields : field_telephonenumber and field_company

how can i display them in user.html.twig or maybe page.html.twig

1 Answer 1


You can configure which fields are displayed in the view mode compact:


Then you can in twig display all fields with

{{ content }}

or single fields with

{{ content.field_example }}

To put a user in a page template you can use Twig Tweak:

{{ drupal_entity('user', 1, 'compact')

The third parameter is the view mode and you can use theme hook suggestions to catch this with your custom user twig to make adjustments of the user fields.

  • 1
    What part of it did not work? And don't change the question, so that the answer doesn't fit anymore.
    – 4uk4
    Oct 27, 2016 at 9:58
  • I changed the page because i made a mistake but i tested your answer on both pages the {{ content.field_example }} didn't work
    – usethe23
    Oct 27, 2016 at 12:14
  • 1
    Your first question was about the user twig. This is, where you normally display user fields. If you now ask, how to display user fields in other twigs, like a page twig, this is too broad for an answer. You need to be more specific.
    – 4uk4
    Oct 27, 2016 at 12:58
  • I tried to display it in a user.html.twig page but it didn't work so i wanted to try maybe with something else and still it didn't work. I'm sorry i should've edited my question to say on any page possible, thank you for your help
    – usethe23
    Oct 27, 2016 at 13:17
  • 1
    For user twig the key is to add the new fields to the view mode. For page I put one possible solution in the answer.
    – 4uk4
    Oct 27, 2016 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.