I started using custom blocks for reusable content on a website. It turns out twig works a bit different on block content than on paragraphs.

A working example:

<section{{ attributes.addClass(classes) }} style="background-image: url({{ file_url(content.field_hero_image.0['#item'].entity.uri.value) }});">

and another

{% if content.field_link %}
  <a href="{{ content.field_link.0['#url'].toString() }}" class="btn btn-primary btn-orange">{{ content.field_link.0['#title'] }} &gt;</a>
{% endif %}


Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!