Laravel News Digest – Behind the Scenes
Published on by Eric L. Barnes
I’ve been writing a weekly Laravel newsletter for 6 weeks now. Every week I try to share a personal story, Laravel tip, or some form of story that’s on my mind. I also include a list of posts, random web links, quotes, and other things. Here is a full archive if you want to see them.
In this post I wanted to share how I create these. At the start I created each one by hand, and by hand I mean I literally copy and pasted html tables all over the place and after I finally felt I had some sort of structure I would spend another hour or two making sure it worked in every mail client my devices support.
Design
I’m a big fan of minimal sites. I like the cleanliness and the focus on the fonts and words. More so than images and graphics. Of course with email you can’t get very fancy anyway or you could be in a world of hurt. I decided to go with a very clean response white and grey layout. I don’t have any stats to back this up but my thoughts are since I send these on a Sunday most of my readers will receive it on a mobile device, so having a minimal responsive theme was important.
For the template I used Zurb email templates and just went with their basic example. One nice thing I did come across however is that you can use custom fonts in email with a few caveats. You can use Google fonts, or you can use your own if you purchase the font and import into CSS. In my case I just picked two from Google, Lato and Oswald, and went with it. I’ll be honest I’m not sure how widely these are supported but they worked on all my devices, plus I used the good old fashioned fallbacks of Arial and Helvetica.
Another trick is to import the css file directly into the template. This way when you copy and paste into an inliner, it can pull styles from the source. Here is a simple way in blade:
<style type="text/css"> {{ include(public_path().'/css/newsletter.css') }}</style>
HTML
I finally got fed up with the process of copy and pasting blocks of html tables and decided to make it better, and when I say better I mean better for me. You might think this is all dumb. :) The first step was getting away from HTML as much as possible. Nested tables are brutal without Dreamweaver and I’m not going down that path. I do love markdown and that’s what I wanted to write in. This gives me lots of benefits and my workflow is simple. Each week I create a new file and throughout the week I add to it anything I find interesting: notes, links, quotes, etc.
I then take the finished markdown file and parse it. I follow this structure in my file:
first section --break-- second section --break-- --posts-- <- This tag gets converted to a list of posts --break--
With this I just “break” apart each section, run it through markdown, and then loop it in a view:
@section('content') @foreach ($contents as $section) @if (trim(strip_tags($section)) == '--posts--') @include(theme_view('newsletter.inc.posts')) @else @include(theme_view('newsletter.inc.section-start')) {{ $section }} @include(theme_view('newsletter.inc.section-end')) @endif @endforeach@stop
The finished parsed file is then ready for me to go through as many times as I need. I read and re-read these way more than I should. I pretend I’m a sniper with only one shot, so I strive to make it the best I can.
Once I’m comfortable with all the text then all that is left is to view source, copy and paste into the inliner, and schedule it for Sunday afternoon in my newsletter system.
Stats
To share a few stats so far I am getting around an 80% open rate with 1% unsubscribes. I’ve heard from a few sources that the bigger the list grows the open rate will typically decrease to around 50%, and the 1% is average. So I’m overall happy with my first few weeks into this experiment.
When I started this I never imagined the time and effort that I would put into it. Thinking about it now I should have just imported a list of this weeks posts, sent those, and be done. :)
Eric is the creator of Laravel News and has been covering Laravel since 2012.