Creating a basic email template

FeedOtter templates start life as high-quality, well-tested HTML email templates. By adding loops and tokens we can make them compatible with FeedOtter.

In the previous article we talked about the basic elements found in every FeedOtter template. Let's expand on that further by placing our LOOP code in an existing email and then adding some common tokens to display post data in the desired location.

Original HTML Email Template

Here is a plain HTML email template. Our logo and footer text are coded in place and our email team created some fake placeholder content.

Content Loop Placement

View the HTML code of your template and look for a suitable <table> or <tr> that wraps around the first row of content. This will vary by email but it is very important to look up and down the HTML tree to find the most-outward row or table that encloses the region of content you wish to repeat.

Place the loop start code above the repeating area's opening HTML tag:

<!--## [% for post in feedotter.posts %] ##-->

and the end loop code after the related closing tag.

<!--## [% endfor %] ##-->

This is a technical job and requires knowledge of basic HTML structure, opening and closing tags. If the loop code is placed in the wrong place your template will never work correctly or compatibility may suffer. If you are unsure where to place this code please ask for help from your HTML email coder.

Once you have placed the FeedOtter loop around a row of content you can delete all other rows. Since we are looping through the content only 1 article row, wrapped in the loop code is needed.

Now our email looks like this:

Adding Post Tokens

Adding Post Tokens inside our loop will allow FeedOtter to display your articles content. Here are the common tokens used.

Paste the appropriate token into your HTML email code in-place of the placeholder data.

The Most Common Post Loop Tokens

Merge codeDescription and Usage

[[post.post_title]]

The title of an article.

[[post.post_excerpt_text]]

The description text or slug for an article. This value is automatically created by using the best option between the Description text and Content. All incoming HTML is stripped.

[[post.post_url]]

The website URL of the article.

[[post.image_url]]

The best featured image that represents the article as chosen by our algorithm. Learn more about how FeedOtter selects campaign

images here.

The [[post.image_url]] token is not relevant to the example template we are displaying but it is very common to use this to display a great looking featured image with each article.

Loop and Tokens in Place

With the loop and tokens in place our HTML email look like this:

...and if we preview it in FeedOtter's interface we can see our loop and tokens successfully merging with real content.

Full Code

Here is the full code example of the finished email. Paste this example below into your FeedOtter account(see Moving your email template to FeedOtter to learn how) to see how our loop and tokens appear when used with FeedOtter.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml><![endif]-->
<title>[[feedotter.company_name]]</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0 " />
<meta name="format-detection" content="telephone=no"/>
<style type="text/css">
body {
    margin: 0 auto;
    padding: 0;
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    -webkit-font-smoothing: antialiased !important;
}
img {
    border: 0 !important;
    outline: none !important;
}
p {
    Margin: 0px !important;
    Padding: 0px !important;
}
table {
    border-collapse: collapse;
    mso-table-lspace: 0px;
    mso-table-rspace: 0px;
}
td, a, span {
    border-collapse: collapse;
    mso-line-height-rule: exactly;
}
.ExternalClass * {
    line-height: 100%;
}
.em_defaultlink a {
    color: inherit;
    text-decoration: none;
}
.em_defaultlinku a {
    color: inherit;
    text-decoration: underline;
}
.em_g_img + div {
    display: none;
}
a[x-apple-data-detectors], u + .em_body a, #MessageViewBody a {
    color: inherit;
    text-decoration: none;
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
    line-height: inherit;
}

@media screen and (max-width: 649px) {
.em_main_table {
    width: 100% !important;
}
.em_wrapper {
    width: 100% !important;
}
.em_hide {
    display: none !important;
}
.em_full_img {
    width: 100% !important;
    height: auto !important;
}
.em_full_img img {
    width: 100% !important;
    height: auto !important;
}
.em_center {
    text-align: center !important;
}
.em_left {
    text-align: left !important;
}
.em_side10 {
    width: 10px !important;
}
.em_aside10 {
    padding: 0px 10px !important;
}
.em_side15 {
    width: 15px !important;
}
.em_aside15 {
    padding: 0px 15px !important;
}
.em_ptop {
    padding-top: 20px !important;
}
.em_pbottom {
    padding-bottom: 20px !important;
}
.em_p10 {
    padding: 10px !important;
}
.em_p15 {
    padding: 15px !important;
}
.em_plrb15 {
    padding: 0px 15px 15px 15px !important;
} /* Padding Left Right Bottom */
.em_h20 {
    height: 20px !important;
    font-size: 1px!important;
    line-height: 1px!important;
}
.em_h30 {
    height: 30px !important;
}
.em_bg_none {
    background-image: none !important;
}
.em_mob_block {
    display: block !important;
}
.em_hauto {
    height: auto !important;
}
.em_clear {
    clear: both !important;
    width: 100% !important;
    display: block !important;
}
u+.em_body .em_full_wrap {
    width: 100%!important;
    width: 100vw!important;
}
.em_ptop30 {
    padding-top: 30px !important;
}
.em_pbottom30 {
    padding-bottom: 30px !important;
}
}
</style>
</head>
<body class="em_body" style="margin:0px auto; padding:0px; background-color:#ffffff;" bgcolor="#ffffff">
	<div class="preheader " id="Preheader"
     style="mso-hide:all;visibility:hidden;opacity:0;color:transparent;mso-line-height-rule:exactly;line-height:0;font-size:0;overflow:hidden;border-width:0;display:none !important;">
    <p style="margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;">Prehader Text Goes Here... FeedOtter has a token you can use for this as well!</p>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="em_full_wrap" bgcolor="#ffffff" style="background-color:#ffffff; table-layout:fixed;">
  <tr>
    <td align="center" valign="top"><table align="center" width="650" border="0" cellspacing="0" cellpadding="0" class="em_main_table" style="width:650px; table-layout:fixed;" bgcolor="#ffffff">
        <!-- == Logo_Image Section == -->
        <tr>
          <td valign="top" align="center"><table width="650" border="0" cellspacing="0" cellpadding="0" align="center" style="width: 650px;" class="em_wrapper">
              <tbody>
                <tr>
                  <td width="25" style="width: 25px;" class="em_side15">&nbsp;</td>
                  <td valign="top" align="center" style="padding-top: 30px; padding-bottom: 52px;" class="em_pbottom30"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                      <tbody>
                        <tr>
                          <td valign="top" align="left"><a href="https://www.feedotter.com" target="_blank" style="text-decoration: none;"><img src="https://fodevuc.sfo2.cdn.digitaloceanspaces.com/ee6f25117bf6/5eaa66a2-4e3f-11ed-8c71-ee6f25117bf6.png" width="220" alt="FeedOtter newsletter" style="display: block; border: 0px; max-width: 220px; font-family: Arial, sans-serif; color: #000000;" class="em_g_img" /></a></td>
                        </tr>
                      </tbody>
                    </table></td>
                  <td width="25" style="width: 25px;" class="em_side15">&nbsp;</td>
                </tr>
              </tbody>
            </table></td>
        </tr>
      
		
<!--## [% for post in feedotter.posts %] ##-->


        <tr>
          <td valign="top" align="center"><table width="650" border="0" cellspacing="0" cellpadding="0" align="center" style="width: 650px;" class="em_wrapper">
              <tbody>
                <tr>
                  <td width="25" style="width: 25px;" class="em_side15">&nbsp;</td>
                  <td valign="top" align="center" style="padding-bottom: 50px;" class="em_pbottom30"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                      <tbody>
                       
                        <tr>
                          <td valign="top" align="left" style="" class="em_defaultlink">
                          <a href="[[post.post_url]]" target="_blank" style="text-decoration-line: none; font-family: Helvetica, Arial, sans-serif; color: [[feedotter.button_color]]; font-size: 18px; line-height: 21px; font-weight: 700; padding-bottom: 10px;">
                          [[post.post_title]]</a></td>
                        </tr>
                        <tr>
                          <td valign="top" align="left" style="font-family: Helvetica, Arial, sans-serif; color: #000; font-size: 15px; line-height: 21px; font-weight: 400; padding-bottom: 10px;" class="em_defaultlink">[[post.post_excerpt_text]]</td>
                        </tr>
                        <tr>
                          <td valign="middle" align="left" style="font-family: Helvetica, Arial, sans-serif; color: #000; font-size: 12px; line-height: 15px; font-weight: 700;" class="em_defaultlinku"><a href="[[post.post_url]]" target="_blank" style="text-decoration: underline; color: [[feedotter.button_color]];">Read More&nbsp;&nbsp; &#10132;&nbsp;</a></td>
                        </tr>
                      </tbody>
                    </table></td>
                  <td width="25" style="width: 25px;" class="em_side15">&nbsp;</td>
                </tr>
              </tbody>
            </table></td>
        </tr>
		<!--## [% endfor %] ##-->
        <!-- == Footer Section == -->
        <tr>
          <td valign="top" align="center"><table width="650" border="0" cellspacing="0" cellpadding="0" align="center" style="width: 650px;" class="em_wrapper">
              <tbody>
                <tr>
                  <td width="25" style="width: 25px;" class="em_side15">&nbsp;</td>
                  <td valign="top" align="center" style="padding-bottom: 40px;" class="em_pbottom30"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
                      <tbody>
                        <tr>
                          <td valign="top" align="left" style="font-family: Helvetica, Arial, sans-serif; color: #666; font-size: 14px; line-height: 16px; font-weight: 700; padding-top: 30px; border-top: 2px solid #666;" class="em_defaultlink"></td>
                        </tr>
                        <tr>
                          <td valign="top" align="left" style="font-family: Helvetica, Arial, sans-serif; color: #000; font-size: 14px; line-height: 21px; font-weight: 400; padding-top: 18px;" class="em_defaultlink">
								
<span style="color:#000;"><strong>FeedOtter</strong><br>1334 West Elm St.<br>Boulder, CO 66503<br><br>Copyright © 2022<br><a href="{{unsubscribe}}" style="color:[[feedotter.footer_text_color]];" target="_blank">Unsubscribe</a></span>
							</td>
                        </tr>
                      </tbody>
                    </table></td>
                  <td width="25" style="width: 25px;" class="em_side15">&nbsp;</td>
                </tr>
              </tbody>
            </table></td>
        </tr>
        <!-- == //Footer Section == -->
      </table></td>
  </tr>
</table>
</body>
</html>

Last updated