ssg and org-mode

ssg is a small shell script for generating static sites using Markdown. It's major claim to fame is being small and simple. While simplicity is good, Markdown is not super expressive and one has to drop to HTML to do complicated things. org-mode on the other hand is simple and expressive.

org-mode already has a way to turn org-mode files into HTML but it can be a pain to setup and it also generates complicated HTML. But org-mode can export to Markdown.

To do this, a Makefile will be used to convert .org files to .md files. Then ssg will be run on the .md files. Because ssg just does a blind rsync of the generated content the .org files are deleted from the output. This isn't strictly necessary.

Directory Structure

Below is the directory structure of the project. The src directory .org files and the html directory is the generated output, in this case.

├── Makefile
├── bin
│   └── ssg
├── html
│   ├── index.html
│   ├── rss.xml
│   ├── sitemap.xml
│   └── ssg-and-org-mode
│       └── index.html
└── src
    ├── _ssg.conf
    ├── _styles.css
    └── ssg-and-org-mode


This Makefile assumes that there is an in the src directory and that all other content is one directory deeper, named as well.

.PHONY: all clean

posts=$(wildcard src/*/

export DOCS=$(PWD)/html

all: src/index.html

src/index.html: src/ $(md_posts)
    mkdir -p "$(DOCS)"
    cd src && ../bin/ssg build
    find "$(DOCS)" -name '*.org' -delete
    find "$(DOCS)" -name '*~' -delete
    emacs $< --batch -f org-md-export-to-markdown --kill




Finally, when using the HTML publishing feature of org-mode one can link to other .org files and they will be automatically published. That is not the case here, so any links to generated content must link to the .html file.

For example,

#+OPTIONS: toc:nil

* Articles

- [[file:ssg-and-org-mode/index.html][ssg and org-mode]]