Jekyll to Hugo

· 131 words · 1 minute read

花了点时间从 Jekyll 切换到了Hugo,好处是:不用维护一个 Ruby 环境,这样可以方便的写笔记,而不用太关心平台问题。

又写了一个简单的脚本自动创建新帖子:

#!/usr/bin/env bash

set -e

: ${BLOGDIR:=$HOME/Documents/git-repos/live4thee.github.com}
: ${HUGOCMD:=$HOME/bin/hugo}

test -d $BLOGDIR || ( echo "$BLOGDIR not accessible"; exit 1 )
test -x $HUGOCMD || ( echo "$HUGOCMD not accessible"; exit 1 )
test $# -eq 1 || ( echo usage: $(basename "$1") post-name; exit 1 )

pname=$(echo "$1" | sed 's/[^a-zA-Z0-9]/-/g')
pname=$(printf "%s-%s.md" $(date +"%Y-%m-%d") "$pname")

cd "$BLOGDIR"; $HUGOCMD new "post/$pname"
comments powered by Disqus