Homepage

Using Email Layouts

Last edit: Oct 26, 2022

This guide will help you provide a layout for your Email Notifications.

Requirements

As the concept of an email layout is the same as the concept of a layout for pages, you should understand the concepts of layouts and notifications, and should have created an Email Notification before.

Steps

Using email layouts is a three-step process:

Step 1: Create email layout file

The default layout file for all emails should be located in the views/layouts directory. Create a file named mailer.html.liquid.

Step 2: Edit email layout file

The content of an email layout is slightly different from the content of a layout for pages because it needs to be marked as an email layout.

Add the following to your email layout file mailer.html.liquid:


Header

{{ content_for_layout }}

Footer

Where {{ content_for_layout }} injects the body defined in the Email Notification into the layout. Without this part, you would be sending a layout without actual content.

Step 3: Use layout in email

To use the newly created layout in your Email Notification, set layout:

layout: mailer

Next steps

Congratulations! You know how to use email layouts. Now you can learn about including attachments.

Questions?

We are always happy to help with any questions you may have.

contact us