Want to dive right in? Checkout our AMP for Email Starter.
Initial setup
As always, let’s scaffold a new project:./amp-emails, and select the Default Starter.
Choose Yes when prompted to Install dependencies.
Once it finishes installing dependencies, open the project folder in your favorite editor.
Layout
AMP for Email requires some special markup, so let’s create anamp.html Layout and save it under layouts:
layouts/amp.html
Template
For this tutorial, we’ll use the AMP Carousel component. Createemails/amp/carousel.html and add a basic AMP carousel:
emails/amp/carousel.html
<script> tag to the <stack name="head" /> from the layout, as shown above.
You can then use the component’s markup inside <fill:template></fill:template>.
CSS inlining
Inline style attributes are not allowed in AMP, so you need to disable CSS inlining. Do it either globally, in your environment config:config.js
emails/amp/carousel.html
!important
AMP for Email doesn’t support!important in CSS, either.
This can be easily turned off in your Tailwind config:
tailwind.config.js
<style> tag for AMP templates to use a different Tailwind config file:
layouts/amp.html
tailwind.config.js to tailwind.amp.js and disable important:
tailwind.amp.js
maizzle build amp to build your ⚡4email templates.
In case you haven’t installed the Maizzle CLI, add an NPM script to package.json:
package.json
npm run build:amp.