New blogging workflow

Written by



Yesterday night I read about Vercel and found that it offered a free tier to deploy and host static sites.

This site is generated using Middleman I switched to it from Jekyll some years ago in order to run a website here the reasons.

My current workflow is as follows:

Working with git

I have started with git when I started to use jekyll as my blogging platform, I think is the best way to keep your work secure, I have more than a thousand post written and I am sure they are safe.

I have a private server set up as my git server, and I push my blog and some other things there, I mainly work on a laptop configured as dual boot with Windows and Linux, and sometimes on my old Macbook Pro, so I keep mainly three local copies of my blogs.

When I want to write a post, I enter my local copy folder and do a git pull to be sure I have the latest copy to start with

Writing the blog post

I keep a drafts folder inside my git repository and outside my Middleman's source folder, I have all drafts there, so after pulling from the server to my local copy I can continue where I left the last time. Once the post is ready I set the date, modify the file-name to match the date and move the file to the source folder.

If the draft is not ready I just save the file and keep it in the drafts directory.

Generate the static site

When I am ready to publish, I run middleman build in any enviroment I have finished the post, it could be the Macbook Pro, the Dell running Linux, or running Windows (I use WSL with Ubuntu) and the site is ready to be deployed

Rsync to the webserver

At this point I am ready to publish, and I just use an rsync command:

rsync -cazv --delete build/ root@my-server:/var/www/html/blog-folder

Of course I have a bash script that has that command inside, that way I do not have to remember the command with all its options.

Push the blog to the git server

This step is made everytime I stop writing, because the post is ready and published or because I need to stop writing and just save the draft. I push to the git server, that way I can pull again from any place when I have time to keep writing.

I do not completely trust Github or Gitlab or any other, so I keep my own git server and make backups of it, also remember I keep two copies on different machines more or less up to date.

My new workflow

well, now what I will do is just pull, write in the draft folder, and when ready to deploy move the file to source folder and push to the git server.

On the git server there is bare git respository, the central one and the always up to date, but there is also a working tree repository that was cloned locally.

There is also a cronjob running every five minutes that pulls from the bare repo, to working one, and on the working repo there is a post-commit hook that push to github.

So, as soon as I push a new post to my central server, and after a little less than 5 minutes, the working tree of the repo on that server is updated, and pushed to github. When that finally happens Vercel pulls the repo, and runs middleman build for me on their server, and deploys the built copy of my blog.

Final words

I know it would be a lot easier to keep my central repo directly on github, and just push there instead of having the cron job, the git post-hook, but if I want to have my own git server, this is the only way, it goes against KISS principle, but it is working.

And now I can write on my iPad and as soon as I push to the server the magin happens and the new post is published, I can now post on the go.

One last thing, If I wouldn't want to use Vercel, I could also have middleman installed on my web server, and with a post-hook run middleman build and deploy to the Apache folder, I have done that in the past, I blogged about that here