How To Edit A Ghost Email Newsletter Template

Ghost is a popular open-source CMS system that people increasingly use as a free alternative to Substack, ie to publish email newsletters.

You have the option of either self-hosting Ghost, or using the Ghost managed service, Ghost Pro. Unfortunately, if you use Ghost Pro, you can't actually change the look of the email newsletter, because its formatting is in the core files.

This means that if you want to customize the email newsletters, you have to fork the Ghost repo, modify the appropriate files, and then put it in a docker image, and host it somewhere yourself.

This blog post shows you the easiest way to do this.

1. Fork the Ghost repo

Follow the instructions here to fork the Ghost repo and get it up and running locally.

2. Edit the template.js file

Navigate to core/server/services/mega/template.js and make the modifications that you want. Be careful, html and css rendering in email is very fragile. Email clients very rarely render HTML5 or CSS3 so keep it simple.

3. Create a release zip

To create a release zip, run from root of the forked Ghost repo:

grunt release

Your release zip will be in .dist/releaseand will be named Ghost-{version}.zip

4. Wrap the release zip in a Docker container

  1. Fork this repo
  2. Clone the forked repo
git clone <forked repo url>
  1. Copy the release zip from into the root of this forked repo
	cp Ghost-for-render.zip ~/ghost-2/
  1. Open up the Dockerfile from the root of the forked repo and replace all mentions of the old zip file with the new release zip.
  1. Commit your changes and push them to Github
git add .
git commit -m "Add release zip"
git push

5. Deploy the Docker container as a Docker web service on Render

Click the "Deploy to Render" button in the Readme of the forked Github repo on Github and create a Render Docker Web Service.