Feature announcement: introducing Layouts for reusable components in Templates
Rejoice with us, Postmark Template users, for today is a good day. In our previous big enhancement to Templates we introduced template pushing to make it easier to manage templates across environments. We also recently released the official command-line interface for Postmark, which makes Templates even more tightly integrated with your existing development workflow.
But there was one feature that I know you have been waiting for the longest: the ability to reuse components across Templates. We know how frustrating it is to edit common elements like the date in a footer, or a logo, or a design change you want to make across all your Templates. So today we are really excited to announce the release of Postmark Layouts — a way to define common elements like CSS, Headers, and Footers, and reuse those Layouts across many Templates.
How it works #
With this release, you are able to extract all the common elements from your emails, and add them to a Layout. Each Template that uses the Layout will inherit the common elements from that layout, and all you have to do is write the message content and include any calls to action you might need. The diagram below shows how this works:
![](https://craft-assets-staging.postmark-testing.com/blog/_616x354_crop_center-center_10_none/layouts1.png)
When you go to the Templates section of your account you will now see a new tab called “Layouts” where all your reusable content lives:
![](https://craft-assets-staging.postmark-testing.com/blog/_800x556_crop_center-center_10_none/layouts2.png)
We’ve made it really easy to create new Layouts and use them with your Templates. You can add Layouts independently, or do it as part of creating a new Template. What’s more, pushing from one server to another now pushes both Templates and Layouts, so testing global changes and then making it live across all your emails is really easy as well.
A quick detour on Partials vs. Layouts #
I can hear that question in the back of your head… why did we go with a Layout approach, and not Partials, like many other email providers do? We did extensive research before and during the development of this feature, and what we heard from the vast majority of developers is this: even though Partials seem like the “right” way to go, Layouts are way simpler to understand and use, and covers most (if not all) of the possible use cases you have. We heard that all you want to do is extract the CSS from your emails, and be able to make changes to headers and footers once across multiple Templates.
As we were working on the feature our initial instinct was to just implement Partials because “everyone is doing it.” But we realized early on that Layouts is a more elegant solution to the problem we’re trying to solve, so we validated the idea with customers, you agreed, and off we went.
What’s next… #
Ready to get started? Excellent. We have a couple of resources to get you on your way:
- This help doc explains the ins and outs of using the feature in the UI.
- We also updated the API so that you can manage Layouts easily, and we’ve updated our developer docs with the new endpoints and responses.
- Mustachio (our templating engine for C# and other .net-based languages) has been updated with Token Expanders to make it easier to work with our new Layouts feature.
Over the coming weeks we’ll also add layout support to our official libraries, the Postmark CLI tool, and MailMason.
This release marks the final step in a long journey to build a Templating system that lets you confidently send your email without worrying about how it will work in different email clients. We really hope you enjoy the new Layouts feature, and would love to hear your feedback. Just get in touch — I read and respond to every email!