Set up DMARC and see who's sending email using your brand's domain.
x

Using Postmark Layouts

Layouts let you generate reusable code for Templates in Postmark. Layouts are perfect for wrapping your email Templates with reusable CSS styles, headers, and footers.

Previously, if your Templates shared common CSS elements, or headers and footers, the code for each Template needed to be managed independently. With Layouts, your receipts, welcome emails, and password reset can share common elements. Each individual Template only contains the content of the email, while the reusable content is shared with the chosen Layout.

Layouts Overview Diagram

Using Layouts

To give you a head start, Postmark comes with a few starter Layouts. The adventurous can also code their own Layout from scratch.

Adding a Layout

  1. Navigate to one of your Postmark Servers, and select Templates.
  2. Choose Layouts then Add layout.
  3. Postmark will show our built-in starter layouts. For this example, we’ll choose Basic.
  4. After selecting the layout, it’s added. You’re now ready to create a beautiful Layout for your Templates.

Editing Layouts

After adding your layout, it’s a snap to edit it using Postmark’s editor. In the editor, you can add or edit the HTML and CSS, then see a live preview.

Like Postmark’s starter Templates, the starter Layouts include CSS in a style block in the head of the email, instead of inline with the content like most email clients prefer. Postmark will automatically inline those styles when the email is delivered. This makes it easier for you to edit while still bringing all the benefits and reliability of inlining.

To indicate where your template content will go, use the content placeholder:

{{{ @content }}}

A single content placeholder is required to save a layout.

By default, the content placeholder is added to the starter Layouts.

Content placeholder in the starter layout

Worried about forgetting the syntax? The Layout editor has a handy button to add the placeholder at your cursor’s location.

Button for adding content placeholder

Associating Templates with a Layout

New or existing Templates can use Layouts.

Add a Layout to a new Template:

When adding the new Template, there’s an option to use the Template with an existing Layout. Or you can add a Layout when creating the Template.

Use an Existing Layout

Use a Layout with an existing Template:

When viewing an existing Template within Postmark’s editor, there is an option to associate the Template with a Layout.

Add a new layout will automatically add a basic layout to the template and associates it to your Template.

After selecting a Layout, choosing Preview will show the Template content as it will appear with the Layout. This lets you see how your Template will look when sending an email. If you have multiple Layouts, you can also switch between Layouts to see how the Template content would appear in different Layouts.

Want to edit a Layout quickly? While viewing the different Layouts you can select a Layout to open in a new window, and edit it. Refreshing the Template page will let you see any Layout changes when previewing.

Layouts

Templates inherit a Layout’s variables

When sending email using a Template, the variables from the Layout are available when using the template model API parameter.

For example, if product_name is a variable from the Layout, when sending a message with the API, the Template can pass product_name in its Template model.

Using an alias with layouts

Each alias for Layouts and Templates are unique to a Server in Postmark. It’s not possible for a Template to have the alias of welcome and a Layout to have an alias of welcome in the same Server.

Pushing layouts to another server

Are you a fan of Postmark’s ability to push Templates from a Server to another? Good news! Along with Templates, pushing Layouts to another Server is possible. Pushing sends every Template and Layout from one Server to another Server.

For example — Let’s say you’ve added a Layout and associated Templates to your staging server. With pushing, after testing the Templates, you’re able to push the Templates and Layouts to your production server.

To push Layouts and Templates

  1. Navigate to one of your Postmark Servers, and select Templates.
  2. Choose Push to another server.
  3. The changes about to be pushed will display. Along with the ability to preview the changes.
  4. Once you’re ready to push, select Push now.

Pushing Layouts and Templates

How to view which Templates are using a Layout

  1. Navigate to one of your Postmark Servers, and select Templates.
  2. Choose Layouts.
  3. When viewing the Layouts, its listed which Templates are using it.

Pro Tip: Hovering over n templates will show the Templates using the Layout.

Last updated June 9th, 2023

Still need some help?

Our customer success team has your back!