PeterSmith.Org

Posting to Pelican

    I've been playing around trying to make the process of posting easier. I've taken an idea from Pelican Tips n Tricks and modified my Makefile (well, actually, on FreeBSD one needs to use gmake or similar when using Pelican as its version of make is rather BSD in orientation).

    Anyway, I've tweaked my Pelican created Makefile to include:

    
    PAGESDIR=$(INPUTDIR)
    DATE := $(shell date +'%Y-%m-%d %H:%M:%S')
    SHORTDATE := $(shell date +'%Y-%m-%d-')
    EXT ?= md
    
    newpost:
    ifdef NAME
        echo "Slug: $(SLUG)" >> $(INPUTDIR)/${SHORTDATE}$(SLUG).$(EXT)
        echo "Date: $(DATE)" >> $(INPUTDIR)/${SHORTDATE}$(SLUG).$(EXT)
        echo ""              >> $(INPUTDIR)/${SHORTDATE}$(SLUG).$(EXT)
        echo ""              >> $(INPUTDIR)/${SHORTDATE}$(SLUG).$(EXT)
    else
        @echo 'Variable NAME is not defined.'
        @echo 'Do make newpost NAME='"'"'Post Name'"'"
    endif

    I suspect I could of make things a little cleaner but it works. It allows me to do things like:

    
    gmake newpost NAME='Posting to Pelican'

    That will create a file in my content directory called:

    2014-12-17-posting-to-pelican.md

    I like to date all my filenames to stop any 'clashes' and to reduce the liklihood of me accidently overwriting an old post.

    It's a step in the right direction.

    Of note, I found out the hard way, that the indents in a gmake Makefile (and presumably in a regular Linux Makefile) have to be TAB characters and not just spaces. That had me going around in circles for a few minutes.


    Webmentions
    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: 300 (about 2 minutes)

    Published:

    Updated: 17 Dec '14 19:54

    Author: Peter Smith

    Permalink: https://petersmith.org/blog/2014/12/17/posting-to-pelican/

    Section: blog

    Kind: page

    Bundle type: leaf

    Source: blog/2014/12/17/posting-to-pelican/index.org