How to theme table row to link particular column data? I have created a list of table records in admin section using the following code.

class userDownloadedFiles extends ControllerBase{ public function userList() {
$header = array(

  array('data' =&gt; $this-&gt;t('Username'), 'field' =&gt; 'name', 'sort' =&gt; 'asc'),
  array('data' =&gt; $this-&gt;t('Email'), 'field' =&gt; 'mail', 'sort' =&gt; 'asc'),
);

$db = \Drupal::database();
$query = $db-&gt;select('users','u');
$query-&gt;innerJoin('users_field_data','ufd','u.uid=ufd.uid');
$query-&gt;fields('ufd', array('name','mail'));
$table_sort = $query-&gt;extend('Drupal\Core\Database\Query\TableSortExtender')
                    -&gt;orderByHeader($header);
// Limit the rows to 20 for each page.
$pager = $table_sort-&gt;extend('Drupal\Core\Database\Query\PagerSelectExtender')
                    -&gt;limit(20);
$result = $pager-&gt;execute();

// Populate the rows.
$rows = array();
foreach($result as $row) {
  //Get URL to user profile
  $profile_url = \Drupal::service('path.alias_manager')-&gt;getAliasByPath('/user/'.$row-&gt;uid);

  $rows[] = array('data' =&gt; array(
    'name' =&gt; "&lt;a href='$profile_url'&gt;$row-&gt;name&lt;/a&gt;",
    'mail' =&gt; $row-&gt;mail,
  ));
}

// The table description.
$build = array(
  '#markup' =&gt; t('List of users who have downloaded model drawing or requested an account for downloading one.')
);

// Generate the table.
$build['user_info_table'] = array(
  '#theme' =&gt; 'table',
  '#header' =&gt; $header,
  '#empty' =&gt;t('There are no records yet.'),
  '#rows' =&gt; $rows,
);

// Finally add the pager.
$build['pager'] = array(
  '#type' =&gt; 'pager'
);
return $build;  }}


But the a tag used in username column is displayed as it is not appearing as link. This is how it appearing 

Please guide me how to make it likable and how would I do it for other columns too.
You can try using the render element syntax for a Link element, like this:

$rows[] = array(
  'name' =&gt; array(
    '#title' =&gt; $row-&gt;name,
    '#type' =&gt; 'link',
    '#url' =&gt; $profile_url
  ),
  'mail' =&gt; array(
    '#title' =&gt; $row-&gt;mail,
    '#type' =&gt; 'link',
    '#url' =&gt; 'mailto:' .  $row-&gt;mail,
  ),
);


That way you can stick to a more consistent coding style, i.e. render arrays for presentation.