The link render option will render a link without any surrounding HTML elements.
If you want to wrap it in an element you can use the "child" element of the "html_tag" render element to wrap the link.
$output['p_wrapped_link'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'child' => [
'#type' => 'link',
'#title' => $this->t("Home."),
'#url' => Url::fromRoute('<front>'),
],
];
This will render something like this:
<p><a href="https://www.example.com/">Home</a></p>
Add new comment