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
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.
Below is the directory structure of the project. The
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 ├── index.org └── ssg-and-org-mode └── index.org
This Makefile assumes that there is an
index.org in the
src directory and
that all other content is one directory deeper, named
index.org as well.
.PHONY: all clean posts=$(wildcard src/*/index.org) md_posts=$(posts:%.org=%.md) export DOCS=$(PWD)/html all: src/index.html src/index.html: src/index.md $(md_posts) mkdir -p "$(DOCS)" cd src && ../bin/ssg build find "$(DOCS)" -name '*.org' -delete find "$(DOCS)" -name '*~' -delete %.md: %.org emacs $< --batch -f org-md-export-to-markdown --kill
#!/bin/sh ROOT='https://articles.nhmtech.com' WEBSITE_TITLE='NHM Tech Articles' RSS_AUTHOR='SWIM' RSS_DESCRIPTION='NHM Tech Articles'
Finally, when using the HTML publishing feature of org-mode one can link to
.org files and they will be automatically published. That is not the
case here, so any links to generated content must link to the
#+OPTIONS: toc:nil * Articles - [[file:ssg-and-org-mode/index.html][ssg and org-mode]]