If your link field has an internal path (eg /path/foo
), if you output node.field_link.uri
in your twig template, it’ll output internal:/path/foo
into your markup. We need to convert this into a proper URL.
Within preprocess, you can get this with
mytheme.theme
$variables['node']->field_link->first()->getUrl()->toString()
Within twig, you can simply output
template.twig
{{ node.field_link.0.url }}