I'm trying to rewrite the output of a link field in a view in Drupal 8, to include a font-awesome icon, I have tried overriding my view field template in twig, but all i'm getting in the twig template is {{ output }}, which contains a rendered link already.

Desired output

<a href="http://www.facebook.com/profile"><i class="fa fa-facebook"></i></a>

Current output

<a href="http://www.facebook.com/profile">http://www.facebook.com/profile</a>

1 Answer 1


Have you tried doing this through the Views UI? You can use the Rewrite results as per the image below. In the rewrite output you should be able to add your font-awesome div. You might need to use the output this field as a link option to make it clickable (you can use the replacement token of your link field) but that dependends on the field, so I am not sure if it is required.

Rewrite results Source: https://www.drupal.org/node/1578524

  • 2
    I can confirm this will work, however there is a bug at the moment with external url's and rewrite as link in core (8.0.2): drupal.org/node/2488540
    – pjcarly
    Jan 23, 2016 at 21:54

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.