Ghost is a great blogging platform. It's minimalist, fast and looks professional.
But it is still lacking in a number of ways. One such way, is that it lacks a subscribe form editor or template. So let's make our own!
So here is the feature list that I want to implement for this subscribe form:
Super Cool Feature List
Snippet Enabled
Static Background Image + Override image on specific subscribe forms
Change all Subscribe form elements from a central location
Snippet Enabled
Ghost has a snippet system, whereby you can write some text, or even a HTML block and turn it into a snippet. This creates a sort of "blueprint", where you can find the relevant snippet via a drop-down box while creating a blog and simply insert the snippet.
However one pretty severe flaw with this system is that you cannot go back and change the base snippet to alter all the snippets you have essentially pasted. This sucks when you have to go back over 40 blog posts to change the text in a subscribe box (trust me I've done it!). A solution will be outlined in a further step!
Static Background Image Selection
As with all cool features, it would be nice to have the ability to revert without too much hassle. This feature would let the admin change a setting somewhere to let the newsletter know that we want a specific background instead of the default one.
Change all Subscribe form elements
As mentioned previously, we want to use the Ghost snippet tooling, but we also want to be able to change all the specified elements in the snippet from a central location. The elements we would like to change are:
Title
Description
Background Image
Time To Code
So where do we start?
The first we should do is create our basic form structure, we are going to start with our main div:
Now we can add the title element:
Now let's add the description element:
Once we have that we can add the main form element:
Now we finally have to add the style for the response messages:
So now on Ghost we can create a blog or a post to place this code in a HTML block:
Then we can create a snippet of it and called it 'subscribe-block':
Now we will create the styling code.
The following code:
Is so that you can add the .subscribeBlock1ImageOverride class to any specific implementation of your snippets so that you can have a custom background image instead of the default one.
So we will put this code into our Ghost settings area.. if want to directly implement it into your theme you can also just ++ but I would recommend just putting it into the Ghost settings area and ensure you back it up somewhere in case it ever gets deleted.
Custom Subscribe Page
Now that we had a subscribe form on our blogs, we can easily update the settings and the change will be reflected on all the blog posts.
Since we have this code ready we can also use it for a subscribe page. So on your Ghost blog create a new page called 'subscribe'
In here we can m
Remove the subscribeBlock1 class so that the snippet will show without the background image.
Now you can open the page settings on the top right corner:
In here you should see the option for code injection on the bottom:
Now we can add the following code into the page header to hide the page title and make the background black.