sblg

+

articles

+

makefile

+

template

=

blog

sblg(1) is a utility for creating static blogs. It knits together articles with templates, generating static HTML files, Atom feeds, and JSON files. It's built for use with make(1), just like any source code. No markdown, no CMS, no CGI, no PHP. Just a simple tool for pulling data from articles and populating templates. sblg(1) is an open source ISO C utility that depends only on libexpat.

How does it work? You write your HTML articles and templates. sblg(1) pulls data from the articles and merges it into the templates. This is all usually orchestrated with a Makefile. There are two basic ways of populating templates: a standalone mode, which pasts a single article into a template (a blog-post permanent link); and amalgation mode, which posts multiple articles (the blog front page). Amalgamation mode can merge entire articles as well as just article snippets and metadata for navigation and summary purposes. You can also do specialty modes of Atom and JSON feeds.

This page itself was created with sblg(1) in amalgamation mode.

To get started, download sblg.tar.gz (SHA512), decompress, and run make install. The current version is 0.3.7, released on . The repository is mirrored on GitHub, if that's easier for you. The last few versions featured the following (this was created by showing only select bits of newest three version articles):

Articles are just content within the <article data-sblg-article="1"> tag of an HTML (or really XML) document. sblg(1) pulls articles and article metadata for populating navigation elements and article elements in the templates. The following is an example article:

<?xml version="1.0" encoding="utf-8"?>
<article data-sblg-article="1">
  <header>
    <h1>Title</h1>
    <address>My Name</address>
    <time datetime="2014-04-12">2014-04-12</time>
  </header>
  <aside>
    This is pulled out for the page synopsis.
  </aside>
  <p>
    And here we have some <q>content</q>.
  </p>
</article>

You'll also need a template. For standalone mode, this is just a regular HTML file where the <article data-sblg-article="1"> tag is replaced by the page contents.

<!DOCTYPE html>
<html>
  <head><title>${sblg-titletext}</title></head>
  <body>
    <article data-sblg-article="1"></article>
  </body>
</html>

For amalgamation (blog) mode it's the same; however, you can also specify <nav data-sblg-nav="1"> to fill in meta-data from all articles passed into the command. The <article> elements will be filled in with articles.

<!DOCTYPE html>
<html>
  <head><title>My Blarg</title></head>
  <body>
    <nav data-sblg-nav="1"></nav>
    <article data-sblg-article="1"></article>
    <article data-sblg-article="1"></article>
    <article data-sblg-article="1"></article>
    <article data-sblg-article="1"></article>
  </body>
</html>

A Makefile makes this easy. Pretend that your articles (article1.xml, article2.xml) are source code. Then object files (article1.html, article2.html) are compiled from single articles and a template, article.xml. Binaries (index.html are compiled from object files (or directly from sources) and a template, index.xml.

XMLS = article1.xml article2.xml
ARTICLES = article1.html article2.html
all: index.html $(ARTICLES)
index.html: index.xml $(ARTICLES)
	sblg -o $@ -t index.xml $(ARTICLES)
.xml.html:
	sblg -o $@ -t article.xml $<

To read about the system, read the sblg(1) manual. I take great care in making sure that the manpage is up to date; less so the non-canonical howto and FAQ documents. That said, this is about blogs, so you might as well have some bloggy stuff. This index is also created dynamically from all howto articles. Unlike the version index above, each links to the full articles, all of which were created with sblg(1)'s standalone mode.