Scheduling a post with Zola and Emile

In a previous post, I’ve explained how I managed scheduling post with a self-hosted Gitea, Cobalt and a fair amount of (messy?) scripting. I have migrated to Zola since and the scripts can’t work anymore. Let’s see how I’m doing it now!

🔗Emile

My workflow uses emile, a tool I wrote in Rust to workaround some stuff missing in zola.

🔗On The VPS

🔗Install The Tools

On my VPS, I put emile and zola in /var/www/bin. I also have git and at installed and available in the PATH.

🔗Work Folder

Like before, I have a copy of the blog repository in /var/www/:

$ cd ~/www
$ git clone https://my_git/blog.git

After zola build, we will have the web site to be served in /var/www/blog/public.

🔗Git Hook

In Gitea, I set the post-receive hook for the blog repo as:

#!/bin/bash
/var/www/bin/call_emile.sh > /var/www/bin/call_emile.log 2> /var/www/bin/call_emile_err.log

call_emile.sh being:

#!/bin/sh
unset GIT_DIR
cd /var/www/blog/
PATH=/var/www/bin:$PATH
emile git-hook

That’s about it for the server! Everything done by my previous shell and awk scripts is manage by emile now.

🔗On The Desktop

🔗PowerShell

Being on Windows, I’ve set some PowerShell functions to create a new post and serving the blog from anywhere:

Function Create-Zola-Post {
Param([string] $Title)
Set-Location -Path H:\Dev\blog\
emile new "$Title"
}

Function Zola-Serve {
Set-Location -Path H:\Dev\blog
zola serve --drafts
}

Set-alias npost Create-Zola-Post
Set-alias serve Zola-Serve

Replace H:\Dev\blog\ by your path and put this snippet in the file shown when you type $profile in PowerShell.

🔗Emile Configuration

In my blog folder, I’m configuring emile like this:

drafts_creation_dir = "content/_drafts/wip/"
drafts_consumption_dir = "content/_drafts/" 
drafts_year_shift = 50
publish_dest = "content/posts/"

Let’s review my workflow now.

🔗Workflow

When I start a now blog post, I call npost "My blog title" which set current directory to my blog’s one, and call emile new with the title. It creates a draft in drafts_creation_dir. Then I call serve and redirect my browser to localhost:1111, enjoying the live reload from zola.

If ever I change the title of my post, I call emile reslug my-blog-title.md and it will rename the post with the new title.

Once the post is ready to be published, I move it into drafts_consumption_dir and commit with this kind of message blog_sched "teatime tomorrow" my-blog-title. This will trigger emile on the VPS to schedule the post!

That’s all folks! I hope some will find this useful!