drupal render element link attributes code example
Example: drupal 8 type link
use Drupal\Core\Url;
$rendable_link = [
'#type' => 'link',
'#title' => $this->t('Link title'),
'#url' => Url::fromRoute('YOUR_ROUTE'),
];
use Drupal\Core\Url;
$rendable_link = [
'#type' => 'link',
'#title' => $this->t('Link title'),
'#url' => Url::fromRoute('YOUR_ROUTE'),
];