Link

Renders a link field and returns a Link object.

Renders a link field from which a creator can select a page, product, blog post, or enter a custom URL. The creator can also choose whether the link opens in a new tab.

Returns: A Link object.

Example

---
attributes:
  cta_link:
    type: link
    label: Button link
    default:
      url: https://easol.com
---
<a href="{{ cta_link.url }}"
  {% if cta_link.new_tab %}target="_blank" rel="noopener noreferrer"{% endif %}>
  Learn more
</a>

Properties

The returned Link object provides:

PropertyDescription
urlThe URL of the link.
new_tabWhether the link should open in a new tab (true or false).

Usage

Links are commonly paired with a string variable for the link text:

---
attributes:
  button_text:
    type: string
    label: Button text
    default: Learn more
  button_link:
    type: link
    label: Button link
---
{% if button_link.url != blank %}
  <a href="{{ button_link.url }}"
    {% if button_link.new_tab %}target="_blank" rel="noopener noreferrer"{% endif %}>
    {{ button_text }}
  </a>
{% endif %}

On this page