drupal 8 link attributes code example
Example 1: drupal 8 type link
use Drupal\Core\Url;
$rendable_link = [
'#type' => 'link',
'#title' => $this->t('Link title'),
'#url' => Url::fromRoute('YOUR_ROUTE'),
];
Example 2: drupal 8 HTML in type link
$link = [
'#type' => 'link',
'#title' => [
'#type' => 'inline_template',
'#template' => '{{ title }} <span class="icon-right-arrow"></span>',
'#context' => [
'title' => $title
],
],
'#url' => Url::fromRoute('user.pass'),
];