manu

Blog with pandoc and markdown

I always wanted to have my own ’lil corner on the net, with some sort of blog to share things with. After messing around for so long, I finally switched to this super simple but reliable solution.

Folder structure

I keep all the files in my ~/docs/blog directory:

├── assets
│   └── css
│       └── style.css
├── content
│   └── index.md
├── partials
│   ├── footer.html
│   └── header.html
├── templates
│   └── default.html5
└── index.html

Everytime I wanna change something, I run the script and all files will be generated again and again. Also I’m lazy, so I don’t want to set a document title, but just use the level one heading.

cd "$(xdg-user-dir DOCUMENTS)/blog"
rm *.html

for f in content/*.md; do
    pandoc -s -f markdown -t html5 --strip-comments \
           -c assets/css/style.css -B partials/header.html -A partials/aside.html -A partials/footer.html \
           --data-dir=. --metadata title="$(cat $f | head -n1 | cut -c 3-)" $f -o $(basename $f .md).html
done

rsync -av . koell:~/html/
cd -

Rsync will upload everything to uberspace then.