Once upon a time, back in June 2011 (last year) I was making my website for Displayator.com and using some bash scripts to make the pages link together (there was only about 3 pages). About the same time, there was a few discussions on HN about the Jekyll and Hyde static site generators. I discovered that Marco Arment had also open sourced its PHP static site generator.
They were using Markdown and a scripting languages, (respectively Ruby
& Python) and I was thinking, do you really need PHP, Python or Ruby
to generate a static blog? As I was already generating a website with
a few lines of
bash spread over a few scripts, I thought “How hard
can it be?”. Anyway, I needed a blog for my Displayator site. So I got
to work with a few constraints and a bonus card:
bashbut no variables nor for loops.
- Fit all the code in a single file.
- Bonus card: I can use a pre-compiled markdown converter.
So I got to work, and soon had something that could pass for a static
blog generator, in less than 60 lines of
bash, including the help
outputs & comments. I took a look, and thought I could shrink it a
bit, by using the
; and cramming a few more things on the same
line. For geek points, I went down to
42 lines of bash, with a few
precious new lines.
To keep in the theme of literary creatures, the result of this assemblage is named ___.sh, after Frankenstein’s creature. It is currently used for the Displayator blog and is the most (only) watched of my projects. Yay!
A few month latter I added the generation of a full text RSS feed, and refactored a bit more to keep the length down at 42 lines.
Today, I renamed it from
Edit on 2012/05/29: restored to the previous name (
___ for neatness' sake.
is not search-engine-friendly enough.
To be able to do so much in so few lines,
___.sh is basically a
script generator written in
bash. It will transform the output of
ls into a
bash script and then pipe it (
|) back to
write the HTML output. The generated commands involve Fletcher
Penney’s MultiMarkdown, and are obtained by applying copious
sed to the
ls results. If you want to see what the
generated command look like, edit
___.sh to replace the few
Unlike Second Crack, Jekyll & Hyde,
___.sh is on the simplistic side of
simple and doesn’t have any option. You can somewhat configure the
HTML outputs by modifiying the - files, which contains the raw HTML
for the non-markdown content of the output. There is also an
index.css that you might want to change.
On the other hand
___.sh only has two dependency:
- a UNIX OS with
- a Markdown to HTML program which must be in the path and called
So, there you go, you can generate a static blog with a few lines of
bash and a binary
markdown compiler. You just need a few thousand
lines of precompiled
More details about how
___.sh comes together is available in the
for once detailed
readme of the project.