How to Add an Email Subscription Plugin on Octopress
Why do you want to add email subscription?
An email subscription form is one of the most common features you see on blogs. Yet it is not present by default on Octopress. Besides RSS feeds, your blog should provide an option for readers to subscribe by email. Having a way to reach your readers is never a bad thing. It is going to look just like the email subscription section you see on this blog(hint: on the right). Luckily, it is simple enough that you can create one in 5 minutes.
Creating a mailing list on MailChimp
We are going to use MailChimp to create a mailing list for your blog readers. We want to create the mailing list and grab the embedded subcription form. If you already know how to do this, skip this section.
After you have created a mailing list, go to the list of mailing lists. There should be an options icon on the right. View the options and select the forms link.
You should be led to the create form page. Find the Share it tab and click it.
You should see the Share it tab. Click on the Create HTML Code For A Small Subscribe Form button.
Select the Naked Form option.
And you should be greeted with the embedded form. Copy the code into your text editor.
Creating the email subscribe section
We are going to add a new aside section on your Octopress config. I am assuming the new subscribe section is located at custom/asides/subscribe.html.
On your subscribe section, add the following code. It should be very similar to the code you copied from MailChimp.
source/custom/asides/subscribe.html
12345678910111213141516171819202122
<section><h1>Subscribe</h1><!-- Begin MailChimp Signup Form --><divid="mc_embed_signup"><formaction="http://url-to-your-mailing-list"method="post"id="mc-embedded-subscribe-form"name="mc-embedded-subscribe-form"class="validate"target="_blank"novalidate><divclass="mc-field-group"><labelfor="mce-EMAIL"> Enter your email to receive updates
</label><inputtype="email"value=""name="EMAIL"class="required email"id="mce-EMAIL"placeholder="you@email.com"></div><divid="mce-responses"class="clear"><divclass="response"id="mce-error-response"style="display:none"></div><divclass="response"id="mce-success-response"style="display:none"></div></div><divclass="clear"><inputtype="submit"value="Subscribe"name="subscribe"id="mc-embedded-subscribe"class="button"></div></form></div><!--End mc_embed_signup--></section>
Remember to replace the form’s action attribute with your own mailing list’s url.
Styling the email subscribe section
Next we want to style the fields. Octopress provides a styles.scss file for your custom CSS styles. We are going to make use of that to style your email subscription form.
// This File is imported last, and will override other styles in the cascade// Add styles here to make changes without digging in too much#mc_embed_signup{// label.mc-field-group>label{margin-top:8px;display:block;}// textfieldinput.email{width:100%;height:24px;margin-top:8px;font-size:14px;}// subscribe buttoninput#mc-embedded-subscribe{background-color:#5DA423;border:1pxsolid#396516;width:auto;background:#2BA6CB;border:1pxsolid#1E728C;-webkit-box-shadow:01px0rgba(255,255,255,0.5)inset;-moz-box-shadow:01px0rgba(255,255,255,0.5)inset;box-shadow:01px0rgba(255,255,255,0.5)inset;color:white;cursor:pointer;display:inline-block;font-size:14px;font-weight:bold;line-height:1;margin:8px000;outline:none;padding:10px20px11px;position:relative;text-align:center;text-decoration:none;-webkit-transition:background-color0.15sease-in-out;-moz-transition:background-color0.15sease-in-out;-o-transition:background-color0.15sease-in-out;transition:background-color0.15sease-in-out;}}
Copy the above styles to sass/custom/_styles.scss. And your are done!
12
rake generate
rake deploy
Remember to run generate. If everything looks ok, deploy and watch that mailing list grow.