<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>hugo on Reticulated</title>
    <link>https://reticulated.net/tags/hugo/</link>
    <description>Recent content in hugo on Reticulated</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Tue, 10 Oct 2023 11:46:19 +0000</lastBuildDate><atom:link href="https://reticulated.net/tags/hugo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Creating an RSS Newsletter for your Hugo Blog using Brevo</title>
      <media>https://reticulated.net/posts/creating-an-rss-newsletter-for-your-blog-using-brevo/img/20231010210339.png</media>
      <link>https://reticulated.net/posts/creating-an-rss-newsletter-for-your-blog-using-brevo/</link>
      <pubDate>Tue, 10 Oct 2023 11:46:19 +0000</pubDate>
      
      <guid>https://reticulated.net/posts/creating-an-rss-newsletter-for-your-blog-using-brevo/</guid>
      <description>Automate weekly emails with new posts and allow readers to sign up.</description>
      <content:encoded><![CDATA[<h2 id="it-was-supposed-to-be-so-easyhttpswwwyoutubecomwatchvqikqw-ptij0"><a href="https://www.youtube.com/watch?v=QIKqw-pTiJ0">It Was Supposed to Be So Easy&hellip;</a></h2>
<p><a href="https://reticulated.net/posts/a-developer-blog-for-lazy-developers/">If you&rsquo;re running a blog on a static site generator stack</a>, you may have looked into setting up email automation and a subscriber list. If you&rsquo;re a devout follower of the lazy dev principles, you probably also thought about automating this then noticed all the RSS output controls that frameworks like Hugo provide out of the box.</p>
<p>Great &ndash; Now you just need to find an email service with a free tier and RSS integration &ndash; Easy, right?</p>
<p>I scoured the web for something simple that would work here and found <em>VERY FEW OPTIONS</em>. Most of these services are aimed at marketers more than lazy devs. Even the services that do provide RSS automations only seem to offer them through 3rd parties. On top of that, none of the free tiers seemed to support the RSS automations where they are present.</p>
<figure>
    <img loading="lazy" src="img/20231010210811.png#centered"
         alt="Even Bard doesn&amp;rsquo;t know of a truly free service with any amount of scale."/> <figcaption>
            <p>Even Bard doesn&rsquo;t know of a truly free service with any amount of scale.</p>
        </figcaption>
</figure>

<p>If getting an email server setup and maintained wasn&rsquo;t such a massive pain, I would have thrown up my hands and built something myself here. Thankfully, I&rsquo;ve lived too long at this point to even consider willfully trying to build an email service. Surely that would hurt orders of magnitude more than it would help.</p>
<p>Luckily, there was a service that fit that bill using a 3rd party integration on their free plan: <a href="https://brevo.com/">Brevo</a>. If you know of any services that I missed in my search, please share in the comments below.</p>
<p>The steps below will work for Hugo used with the Papermod theme, but setup should be fairly similar on other themes.</p>
<h2 id="turning-on-rss-in-hugo">Turning on RSS in Hugo</h2>
<p>Turning on RSS in Hugo is as simple as adding a line to your config.yaml file.</p>
<p>Just add RSS to the output&gt;home list:</p>
<div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="nt">outputs</span><span class="p">:</span><span class="w">
</span><span class="w">  </span><span class="nt">home</span><span class="p">:</span><span class="w">
</span><span class="w">  </span>- <span class="l">html</span><span class="w">
</span><span class="w">  </span>- <span class="l">rss</span><span class="w">
</span></code></pre></div><p><a href="https://gohugo.io/templates/rss/">More information available in the docs here.</a></p>
<h2 id="setting-up-brevo">Setting up Brevo</h2>
<p>I might have heard the name <em>Send in Blue</em> in passing, but I wasn&rsquo;t really familiar with this service and only found it after too many Google searches and ruling out the better known players in the space.</p>
<p>Sign up for Brevo with your email and skip through the onboarding process.</p>
<h3 id="connect-your-domain-with-brevo">Connect your domain with Brevo</h3>
<p>After you setup your account and onboard, make sure to navigate to the <code>Senders, Domains, and Dedicated IPs</code> screen to get the DNS TXT records you&rsquo;ll need to add to enable sending from your domain.
<figure>
    <img loading="lazy" src="img/20231010143816.png#centered" width="300px"/> 
</figure>
</p>
<p>I was not prompted to do this during onboarding (probably because I skipped over it) and was confused why my automation was not firing, which will likely happen to you if you dont' follow this step</p>
<h3 id="creating-the-widget">Creating the Widget</h3>
<p>Before we start sending emails, we need a way to collect users' email addresses. We can just use Brevo&rsquo;s Forms for this.</p>
<p>Go to <code>Contacts&gt;Forms</code> on the left side and create a new form. Give the form a name and style it however you want.</p>
<p><img loading="lazy" src="img/20231010150732.png" alt="template design"  />
</p>
<p>Complete the rest of the form setup steps until you get to the Share step. Copy the HTML code from the Embed section of the page.</p>
<p><img loading="lazy" src="img/20231010202726.png" alt="htmlformscreen"  />
</p>
<h3 id="update-hugo">Update Hugo</h3>
<p>Now we need to add our form to Hugo. We&rsquo;ll create a <a href="https://gohugo.io/templates/partials/">partial</a> and a <a href="https://gohugo.io/content-management/shortcodes/">shortcode</a>.</p>
<p>That way, we can automatically include a newsletter sign-up form at the bottom of our default post template, but also have a shortcode to include it at a specific point in a post, like here.</p>
<div class="sib-form" style="text-align: center;
background-color: transparent;                                 ">
<div id="sib-form-container" class="sib-form-container">
<div id="error-message" class="sib-form-message-panel" style="font-size:16px; text-align:left; font-family:&quot;Helvetica&quot;, sans-serif; color:#661d1d; background-color:#ffeded; border-radius:3px; border-color:#ff4949;max-width:540px;">
<div class="sib-form-message-panel__text sib-form-message-panel__text--center">
<svg viewBox="0 0 512 512" class="sib-icon sib-notification__icon">
 <path d="M256 40c118.621 0 216 96.075 216 216 0 119.291-96.61 216-216 216-119.244 0-216-96.562-216-216 0-119.203 96.602-216 216-216m0-32C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm-11.49 120h22.979c6.823 0 12.274 5.682 11.99 12.5l-7 168c-.268 6.428-5.556 11.5-11.99 11.5h-8.979c-6.433 0-11.722-5.073-11.99-11.5l-7-168c-.283-6.818 5.167-12.5 11.99-12.5zM256 340c-15.464 0-28 12.536-28 28s12.536 28 28 28 28-12.536 28-28-12.536-28-28-28z" />
</svg>
<span class="sib-form-message-panel__inner-text">
                 Something went wrong
             </span>
</div>
</div>
<div></div>
<div id="success-message" class="sib-form-message-panel" style="font-size:16px; text-align:left; font-family:&quot;Helvetica&quot;, sans-serif; color:#085229; background-color:#e7faf0; border-radius:3px; border-color:#13ce66;max-width:540px;">
<div class="sib-form-message-panel__text sib-form-message-panel__text--center">
<svg viewBox="0 0 512 512" class="sib-icon sib-notification__icon">
 <path d="M256 8C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 464c-118.664 0-216-96.055-216-216 0-118.663 96.055-216 216-216 118.664 0 216 96.055 216 216 0 118.663-96.055 216-216 216zm141.63-274.961L217.15 376.071c-4.705 4.667-12.303 4.637-16.97-.068l-85.878-86.572c-4.667-4.705-4.637-12.303.068-16.97l8.52-8.451c4.705-4.667 12.303-4.637 16.97.068l68.976 69.533 163.441-162.13c4.705-4.667 12.303-4.637 16.97.068l8.451 8.52c4.668 4.705 4.637 12.303-.068 16.97z" />
</svg>
<span class="sib-form-message-panel__inner-text">
                 Success!
             </span>
</div>
</div>
<div></div>
<div id="sib-container" class="sib-container--large sib-container--vertical" style="text-align:center; background-color:rgba(255,255,255,1); max-width:540px; border-radius:3px; border-width:1px; border-color:#C0CCD9; border-style:solid; direction:ltr">
<form id="sib-form" method="POST" action="https://094c12d9.sibforms.com/serve/MUIFALLkvhMwUn1kNvrYTU7uLg8Uixf4tjLkUKWm1529H_FvNi-y7NWuHyYGkbgomOia8-veELP0qJUvWhBUUYNvrVOdf7EVq4UJI4aO8j6qOpFJa2ugPxWMzs_IOKNn_uvU9JqFQe-eCkyH4xLEv9S8Djswo6lQm9wGs2PDqBPNKY5GwLCT7SMZ-UCLbRzcMNAbv5GkaciXYWPz" data-type="subscription">
<div style="padding: 8px 0;">
 <div class="sib-form-block" style="font-size:32px; text-align:left; font-weight:700; font-family:&quot;Futura&quot;, sans-serif; color:#3C4858; background-color:transparent; text-align:left">
   <p>Subscribe for post alerts!</p>
 </div>
</div>
<div style="padding: 8px 0;">
 <div class="sib-form-block" style="font-size:16px; text-align:left; font-family:&quot;Futura&quot;, sans-serif; color:#3C4858; background-color:transparent; text-align:left">
   <div class="sib-text-form-block">
     <p>Sign-up for the latest <strong>Reticulated.net</strong> posts below</p>
   </div>
 </div>
</div>
<div style="padding: 8px 0;">
 <div class="sib-input sib-form-block">
   <div class="form__entry entry_block">
     <div class="form__label-row ">

       <div class="entry__field">
         <input class="input " type="text" id="EMAIL" name="EMAIL" autocomplete="off" placeholder="EMAIL" data-required="true" required />
       </div>
     </div>

     <label class="entry__error entry__error--primary" style="font-size:16px; text-align:left; font-family:&quot;Helvetica&quot;, sans-serif; color:#661d1d; background-color:#ffeded; border-radius:3px; border-color:#ff4949;">
     </label>
     <label class="entry__specification" style="font-size:12px; text-align:left; font-family:&quot;Futura&quot;, sans-serif; color:#8390A4; text-align:left">
       Provide your email address to subscribe. For e.g abc@xyz.com
     </label>
   </div>
 </div>
</div>
<div style="padding: 8px 0;">
 <div class="sib-form-block" style="text-align: left">
   <button class="sib-form-block__button sib-form-block__button-with-loader" style="font-size:16px; text-align:left; font-weight:700; font-family:&quot;Futura&quot;, sans-serif; color:#FFFFFF; background-color:#0c0e12; border-radius:6px; border-width:0px;" form="sib-form" type="submit">
     <svg class="icon clickable__icon progress-indicator__icon sib-hide-loader-icon" viewBox="0 0 512 512">
       <path d="M460.116 373.846l-20.823-12.022c-5.541-3.199-7.54-10.159-4.663-15.874 30.137-59.886 28.343-131.652-5.386-189.946-33.641-58.394-94.896-95.833-161.827-99.676C261.028 55.961 256 50.751 256 44.352V20.309c0-6.904 5.808-12.337 12.703-11.982 83.556 4.306 160.163 50.864 202.11 123.677 42.063 72.696 44.079 162.316 6.031 236.832-3.14 6.148-10.75 8.461-16.728 5.01z" />
     </svg>
     SUBSCRIBE
   </button>
 </div>
</div>

<input type="text" name="email_address_check" value="" class="input--hidden">
<input type="hidden" name="locale" value="en">
</form>
</div>
</div>
</div>
<p>This is easy to do. Create 2 files <code>layouts/partials/newsletter.html</code> and <code>layouts/shortcodes/newsletter.html</code></p>
<p>You may need to create the folders above in your hugo site if you don&rsquo;t have any custom shortcodes or partials. Now we&rsquo;ll paste the code from earlier in the following files:</p>
<ol>
<li>
<p>We&rsquo;ll copy the CSS code (the first part) into <code>partials/extend_head.html</code>, which you may need to create if it doesn&rsquo;t exist.</p>
</li>
<li>
<p>The 2nd part with HTML code will go in our <code>newsletter.html</code> files that we just created.</p>
</li>
<li>
<p>The last part with JS code we&rsquo;ll place in <code>partials/extend_footer.html</code></p>
</li>
</ol>
<h4 id="update-the-post-template">Update the Post Template</h4>
<p>Create a new file <code>layouts/_default/single.html</code> and copy the contents of <code>themes/Papermod/layouts/_default/single.html</code> into it. This will give us a copy we can override without breaking updates to our theme.</p>
<p>Add a new conditional for our newsletter above the comments.html partial at the bottom of <code>laouts/_default/single.html</code> as shown below:</p>
<pre><code>start of file...
&lt;/footer&gt;

{{- if (.Param &quot;newsletter&quot;) }}
  {{- partial &quot;newsletter.html&quot; . -}}
{{- end }}

{{- if (.Param &quot;comments&quot;) }}
  {{- partial &quot;comments.html&quot; . }}
{{- end }}

&lt;/article&gt;
{{- end }}

</code></pre><p>Now, we include a <code>{{&lt; newsletter &gt;}}</code> shortcode somewhere in a post to render our form. We also can set the parameter <code>newsletter</code> in our frontmatter to control if the form renders again at the bottom of the post.</p>
<p>If you want to include the newsletter at the bottom of a post by default, you can add <code>newsletter: true</code> to your <code>config.yaml</code> file.</p>
<h2 id="setting-up-the-rss-campaign">Setting up the RSS Campaign</h2>
<p>OK &ndash; we&rsquo;re ready to setup our RSS campaign in Brevo. Click your account name in the top right of the screen and go to <code>Plugins &amp; Integrations</code>.</p>
<figure>
    <img loading="lazy" src="img/20231010205003.png#centered" width="300px"/> 
</figure>

<p>Search for RSS and click to start the setup. Enter your RSS feed URL which should be <code>https://domain.com/index.xml</code></p>
<p><img loading="lazy" src="img/20231010205205.png" alt="RSSsearch"  />
</p>
<p>You can setup your own email template using the base RSS template Brevo provides. It works well to load the posts, but you&rsquo;ll probably want to add your logo, colors, etc.</p>
<p>Connect your Newsletter list we created before to the campaign and schedule it for whatever time you&rsquo;d like your emails to go out.</p>
<figure>
    <img loading="lazy" src="img/20231010212630.png#centered" width="400px"/> 
</figure>

<h2 id="final-thoughts">Final Thoughts</h2>
<p>Now, we can collect emails and automatically send out weekly or monthly emails to subscribers.</p>
<p>This will hopefully become a series of posts about enriching and adding features to a static site blog. We&rsquo;ll take a look at analytics through <a href="https://www.goatcounter.com/">goatcounter</a>, setting up comments with <a href="https://cactus.chat/">Cactus Chat</a>, setting up Google Ads, and more.</p>
<p>Thanks for reading!</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
