Newsletter subscribe form

The theme has a newsletter block that displays a newsletter subscription form. It currently supports Mailchimp. To enable it, you will need a Mailchimp form url.

Get the Mailchimp form url

  1. Visit Mailchimp.com and sign up for an account if you do not have one.
  2. Login to your account.
  3. Click on “Audience” in the menu.
  4. Click on “Signup forms”
  5. Select “Embedded forms”
  6. Select “Unstyled forms”
  7. Copy the form action url in html HTML code displayed (view screenshot below for reference)

Configure the Mailchimp integration

Add the Mailchimp form url copied in the previous step to config.toml along as a part of the snippet below.

[Params.Lucid.SubscribeForm]
mailchimpURL = "YOUR MAILCHIMP URL"

displayOnPosts = true
  • The first option sets the Mailchimp url
  • The second option displayOnPosts, displays the newsletter form at the bottom of every blog post.

The displayOnPosts option enables the newletter form at the end of every post. This does not apply to pages on other sections. To add it to other sections or pages, refer below.

You should see something like the following below every post.

Customize the message for the newsletter block

To customize the message for the newsletter block, create a partial file in your Hugo project at the following path

partials/subscribe/message.html

For example, this is my blog’s message partial.

<div class="block-title">Subscribe to my notes</div>
Hey there! I am constantly building stuff and learning things. Twice a month I share notes on what I've learnt.

The block-title class is already styled by the theme. This is how it looks on my blog.

Enable or disable newsletter form on certain posts or pages

To disable the newsletter form on any post, use the following in the frontmatter of the post

subscribeform: false

Similarly, if the newsletter form is disabled site-wide, but if you want to display a newsletter form at the end of a post, set subscribeform: true in your post frontmater. This option can also be used to display newsletter form on pages (where it is disabled by default).

Customize the entire newsletter block

To customize the entire newsletter block, create a file at the below path.

layouts/partials/subscribe.html

Copy the contents of the following file as reference and start customizing.

themes/lucid/layouts/partials/subscribe.html

Embed the newsletter form within a post

The newsletter form can be shown in the midst of any blog post as a part of the post content. To do so, insert the following shortcode anywhere in the post content.

{{< subscribe >}}

Only works for blog posts - content in posts section of your site.

Posts that have the similar keywords as the current post will be shown as recommended posts. For this to work, add keywords to post frontmatter like below.

---
title: Hello World
date: 2021-05-23
keywords:
  - postgresql
  - databases
---

Hide recommended posts

The the post has no keywords OR if there are no related posts for the keywords of the post, then the recommended posts section will not be shown.

To hide the recommended posts section for any post, add showrecommended: false to the post frontmatter.