A Makefile for Jekyll
Getting a Jekyll site running doesn't require much, but Make can still improve your quality of life. Make is a declarative build system that selectively builds components based on a dependency graph that you define. It's not a purpose-built task runner, but it does the job with minimal fuss and was already installed on my machine.
Makefile
Run make to see the available commands.
# .PHONY tells Make that these are aliases, not files it should try to build
.PHONY: help init serve build clean
help:
@echo "init Install Ruby dependencies"
@echo "serve Start dev server with live reload and drafts"
@echo "build Build the site for production"
@echo "clean Clear build artifacts and caches"
init:
bundle install
serve:
bundle exec jekyll serve --livereload --drafts
build:
bundle exec jekyll build
clean:
bundle exec jekyll clean
make init
Installs Ruby dependencies.
make serve
Runs the jekyll serve command with two flags: --livereload for auto-refreshing a page on save, and --drafts so drafts appear alongside published posts.
make build
Builds the project, but does not start the local web server (used for deploys).
make clean
Jekyll uses several cache directories to speed up rebuilds. Use make clean when you want a completely fresh build.
Dev Experience
Clone the repo, run make init then make serve, and you're up and running. Simple and unobtrusive, so you can focus on rewriting your blog post for the fifth time or obsessively fiddling with CSS.