How to send comma separated taxonomy term (as link to taxonomy term url ) from preprocess to twig file as single variable? According to my requirements I have to use views preprocess and views-view.html.twig

function MYTHEME_preprocess_views_view(array &amp;$variables) {


  $aliasManager = \Drupal::service('path.alias_manager');

    if (isset($variables['rows'][0]['#rows'])) {
      $nodeValues = [];
      foreach ($variables['rows'][0]['#rows'] as $value) {

        $nodeValue['created'] = $value['#row']-&gt;_entity-&gt;created-&gt;value;
        $nodeValue['external_url'] = $value['#row']-&gt;_entity-&gt;field_url-&gt;uri;
        $nodeValue['title'] = $title = $value['#row']-&gt;_entity-&gt;title-&gt;value;
        $nodeValue['nid'] = $title = $value['#row']-&gt;_entity-&gt;nid-&gt;value;
        $nodeValue['tid'] = $value['#row']-&gt;_entity-&gt;field_topic-&gt;entity-&gt;tid-&gt;value;

        // section referenced to node
        $nodeValue['section'] = $value['#row']-&gt;_entity-&gt;field_topic-&gt;entity-&gt;name-&gt;value;

        $topics = "";
        foreach($value['#row']-&gt;_entity-&gt;field_topic2 as $val){
          $topics != "" &amp;&amp; $topics .= ", ";
          $topics .= $val-&gt;entity-&gt;name-&gt;value;
        }

        $nodeValue['topics'] = $topics;

        $nodeValues[] = $nodeValue;


      }

      $variables['node_values'] = $nodeValues;
    }

 }


In twig file : 

{% for value in node_values %}
        &lt;div class="link_full"&gt;
            &lt;div class="title"&gt;&lt;a href="{{ value.external_url }}"&gt; {{ value.title }} &lt;/a&gt;
            &lt;/div&gt;
            {% if logged_in %}
                {% if 'premium' in user.getroles %}
                    &lt;div class="link_details"&gt;
                        &lt;div class="timestamp"&gt;&lt;a href="{{ path('entity.node.canonical', {'node': value.nid}) }}"&gt;{{ value.created|date(format='y-m-d H:i') }}&lt;/a&gt;
                        &lt;/div&gt;
                        &lt;div class="topics"&gt;{{ value.topics }}&lt;/div&gt;
                    &lt;/div&gt;
                {% endif %}
            {% endif %}
        &lt;/div&gt;
    {% endfor %}


Out put is like below : 



Everything is working fine but I need to create Links of terms in above screenshot. And in code its TOPICS in preprocess function. 

I have tried various ways to create it as link but that does not work as it just print a tags as html but not links. Please suggest. 

Thanks!
I have solved this like below : 

It was always considered as string so I have to send topics in from of array like below: 

$topics = array();
foreach($value['#row']-&gt;_entity-&gt;field_topic2 as $val){
  $topics[$val-&gt;entity-&gt;tid-&gt;value]= $val-&gt;entity-&gt;name-&gt;value;
}


And then in Twig I made links from them and it worked. 

&lt;div class="topics"&gt;
    {% for key,item in value.topics %}
        &lt;a href="{{ path('entity.taxonomy_term.canonical', {'taxonomy_term': key}) }}"&gt;{{item}}&lt;/a&gt;
        {% if not loop.last %},{% endif %} # for adding commas after each term
    {% endfor %}
&lt;/div&gt;