Using fabric

    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
      TEMPLATE = """
      Title: {title}
      Date: {year}-{month}-{day} {hour}:{minute:02d}
      Category: Blogging
      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.

    If you webmention this page, please let me know the URL of your page.

    BTW: Your webmention won't show up until I next "build" my site.

    Word count: 200 (about 1 minutes)


    Updated: 26 Jan '15 12:19

    Author: Peter Smith


    Section: blog

    Kind: page

    Bundle type: leaf

    Source: blog/2015/01/26/using-fabric/