I've attached file to a node with Media module. I have custom templates/file/file-link.html.twig file, which is rendering the download link with {{ link }} tag.

{{ devel_dump(link) }} outputs this:

enter image description here

I need to print File name as pure text without any link rendering for some cases.

I've tried {{ link.text }}, {{ link.text.string }} and other options, but none of them gave me what I wanted.

2 Answers 2


Maybe this is a render array and you need to use link['#text'] here (sorry if I'm on the wrong track).

Edit: If {{ link.text }} worked on subsequent tries, then my answer is definitely wrong, and the reason for your problem was probably related to caching or something.

  • 1
    Thanks a lot! I don't know why, but {{ link.text }} worked, when I tried it again.
    – bigboy
    Apr 3, 2019 at 9:36
  • That's really odd, and my only guess is that it might have been a caching problem? Apr 3, 2019 at 9:38
  • Could be, but I always clear it before looking for any change. Anyway, thanks a lot for such a quick response for my problem.
    – bigboy
    Apr 3, 2019 at 9:39

I don't know why, but when I tried {{ link.text }} one more time - it worked great!

Maybe I forgot to clear cache, when I used it for the first time, I don't know, but I think I should leave this answer for anyone who will search for it.

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.