Search Menu

From blog to newsletter and back

It is often being said, that software developers should be using their own software, so after many years it was about time for me to get going with my own newsletter. Since I also have a food blog called Vegalicious, the idea was born to send a weekly newsletter with the summary of the posts and comments of the past week.

Managing subscribers
In order to get subscribers for the newsletter I used the new web-forms module in Tripolis Dialogue, which we just released last month. After specifying the database fields and the form details, I only had to add a bit of html with a subscribe form as widget in WordPress.

Widget and form

For the confirmation mails during the registration process I used my own customized design, similar to the final newsletter design.  

confirm mail

In the last mail we send to confirm the successful registration I included a link to the last sent newsletter. This link appears to be very popular. 89% of the subscribers who opened the confirmation mail also clicked on this link since it was added.

Content syndication
Since the purpose of the newsletter was a weekly digest without causing too much extra work, I wanted to automate the process as much as possible and pull in the content directly from WordPress. In Tripolis Dialogue we can create articles based on a RSS or ATOM feed or include any kind of XML feed, and process it directly in the newsletter template. As I didn’t want to duplicate our blog posts I choose the second option. The newsletter has 3 sections: an introduction area, a main area for new recipes and reviews and a sidebar for comments.

Handling the comments was the easiest. WordPress offers comments on blog post as RSS feed, which can be imported directly in the newsletter template:

<#assign commentfeed = xmlImporter("")>

Next I only wanted to display a maximum of 7 comments and in case of a very long comment trim it to 100 characters using standard Freemarker (the templating language we use in Tripolis Dialogue) functions for lists and strings.

<#list as item>
<a href="${}">${item.title}</a>
<#if item.description?length &gt; 100>
   ${item.description?substring(0,100)} (...)
<#if (item_index+1) = 7><#break></#if>
<hr size="1" noshade="noshade" />

Dealing with the recipe and review posts was a bit more challenging. WordPress can supply a feed per month, but not per week. So I had to use the category feeds, which include the 10 most recent posts (this is a WordPress setting). In order to fetch only the posts of the last week I turned the number of feed items to display into a variable parameter of an article, which I can easily change per newsletter. The header and feed URL can also be customized in the same way.


Next I had to deal with the limitations of the RSS format. Our blog posts usually use one or more photos, an introduction, a list of ingredients, cooking instructions etc. An RSS item has a description with the summary of the post excluding any styling and the content of the post with the full html. For the newsletter I only wanted the text of the introduction and a thumbnail image. The images of the blog post are not available as individual elements in the RSS feed, so I extracted the image urls from the html using a regular expression. As sometimes the blog post already uses the thumbnail version of an image, an extra check was necessary.

<#ftl ns_prefixes={"e":""}>
<#assign htmlcontent = item["e:encoded"][0]>
<#assign images = htmlcontent?matches("(<img[^>]*?src=\")(.*?)(.jpg\".*?>)")>
<a href="${}">
<#assign firstImage = images[0]?groups[2]>
<#if firstImage?index_of("150x150") == -1>
   <#assign thumbnail = firstImage + "-150x150.jpg">
   <#assign thumbnail = firstImage + ".jpg">
<img name="" src="${thumbnail}" border="0" 
width="150" height="150" title="${item.title}" alt="${item.title}" />

Vegalicious Weekly in GmailFor the trimming the text after the introduction I wrote a small function in Freemarker which looks for the position of certain keywords in the post (“Yield”, “Servings”, “Ingredients”).
The publishing date of a blog post can be formatted with the built-in Freemarker functions for dates: ${item.pubDate?date(“EEE, dd MMM yyyy”)}

The final version of the newsletter uses 3 RSS feeds (more can be added) and has a custom article for an introduction.

The way back
For outgoing links back from the email newsletter to our food blog I used the Google Analytics support which is integrated in Tripolis Dialogue. This way I can relate web-site visitors directly to our weekly newsletter. The newsletter has been sent 3 times now, twice Saturday night and once on Sunday. Below you can see how this resulted in additional visits on the site. Looks like I have to experiment a bit more with the best moment for sending it.

google analytics campaign results

In total this has been an interesting exercise for me. Although I’ve been working on implementations with customers for many years, that is still different from actually being in the customer role yourself. It gave me some new ideas for our product and it would be great if WordPress would have more flexible content syndication like the blog posts of the last 7 days and images as RSS enclosure element.

Leave a Comment

Required fields are marked *.