This documentation describes unreleased changes on the main branch.

link_attributes()

Twig function of the framework; its result is HTML and is printed without escaping.

{{ link_attributes(link) }}

The attributes of an a element for a link: href (escaped with esc_url()) and, for a link that opens in a new tab, target="_blank" rel="noopener". The output is HTML and is printed unescaped. Returns '' for a link without URL (also a link to content that no longer exists or is not public) or with a URL esc_url() rejects, so check link.url before you print the element. Write classes and other attributes next to it.

{% if attrs.cta.url %}
    <a class="teaser__cta" {{ link_attributes(attrs.cta) }}>More</a>
{% endif %}
ParameterTypeDefaultDescription
linkLinkrequiredThe link, e.g. a Link attribute of the block.

Returns string