Using fabric

26 January 2015

It’s all well and good to use make (or even gmake) to automate the creation of pelican stuff–e.g., uploading to the server, rebuilding the content, etc). But, on Windoz systems ‘make’ is not always available.

As a result I’m looking at fabric. Out of the box, Pelican will install fabric scripts to automate much of the posting/updating process. However, it has taken me a little while to find an examples of using fabric to create new posts (or, more accurately, to easy the creation of new posts). I modified the code a little to use markdown rather than rst, and I added some code to launch vim to edit the post.

import sys
from datetime import datetime

Title: {title}
Date: {year}-{month}-{day} {hour}:{minute:02d}
Category: Blogging
Slug: {slug}
Author: Peter


def newpost(title):
    today =
    slug = title.lower().strip().replace(' ', '-')
    f_create = "content/{}-{:0>2}-{:0>2}-{}.md".format(
    today.year, today.month,, slug)
    t = TEMPLATE.strip().format(title=title,
    with open(f_create, 'w') as w:
    print("File created -> " + f_create)
    local("vim  '{}'".format(f_create))

Anyway, it is working now so I’ll probably propagate this fabfile to the other blogs I’m using.