Twig templates

Make your templates dynamic with Twig

The Twig templating engine is a tool used in web development to simplify the creation and modification of HTML. It allows you to write HTML code mixed with dynamic content, like variables and logic, in a clean and easy-to-read way.

Mailcoach templates support Twig tags, which makes it possible to customise the templates depending on your subscriber attributes.

For example, some of your subscribers may have given their first names, while others may not. In this case, you could create a Twig conditional that displays a different greeting depending on whether you know the subscriber’s first name or not:

{% if subscriber.first_name %}
  Hello, !
{% else %}
  Hello, you!
{% endif %}

There is a lot more you can do with Twig. You can learn more about it and what it is capable of in the Twig documentation.

Ready to get started?