DEV Community

The World's Simplest "Static Site Generator"

David Wickes on October 19, 2018

What's the fastest way to start a blog? Wordpress? Jekyll? Any one of the hundreds of static site generators out there? Nah, it's pandoc and now....
Collapse
 
johnbokma profile image
John Bokma

I have considered Pandoc (it's great, I use it to generate my resume), but in the end I decided to write my own static site generator, also because I want a single input file (Markdown-ish). I use it to generate Plurrrr, a tumblelog.

Collapse
 
weiji14 profile image
Wei Ji • Edited

Excellent post! Here's the oneliner bash loop ;)

for POST in *.md; do pandoc --to=html5 --output=$(basename ${POST%.md}).html --standalone $POST; done
Enter fullscreen mode Exit fullscreen mode

The $(basename ${POST%.md}).html strips out the .md file extension, and also removes the directory path (helpful if your posts are stored in a folder). I found this stackoverflow question a helpful guide.

I'd also recommend eleventy as a no nonsense static site generator.

Collapse
 
gypsydave5 profile image
David Wickes

Not seen the basename trick before - very, very nice.

Collapse
 
quii profile image
Chris James • Edited

Pandoc really is an amazing gift to the open source publishing community.

It does so much.

For instance the book I'm working on is also written in markdown and it's so simple to create a epub files github.com/quii/learn-go-with-test... and pretend you're a real author.

Collapse
 
justinnoel profile image
Justin Noel

Thanks for the great post. Pandoc is pretty fun and simple.

A few edits :

pandoc --output=index.html --to=html5 --standalone index.md

instead of

pandoc --output=index.html --to=html5 --standalone index-world.md
# My Quick Blog

- [Hello World](hello-world.html)
- [My second post](my-second-post.html)

instead of

# My Quick Blog

- [Hello World][hello-world.html]
- [My second post][my-second-post.html]
Collapse
 
gypsydave5 profile image
David Wickes

Publish in haste - regret at leisure!

I'll make the changes - thanks!

Collapse
 
annarankin profile image
Anna Rankin

I love this! I've never used pandoc, gonna check it out now!

IGNORE THE WARNINGS, we don't have time to explain! Ship it now! Now! NOW!

I cracked up 😂

Thanks David!

Collapse
 
gypsydave5 profile image
David Wickes

Thanks Anna - that made my day!

Collapse
 
hypeddev profile image
Oliver Williams

Have you tried Netlify?

Collapse
 
gypsydave5 profile image
David Wickes

No - tell me about it!

Collapse
 
hypeddev profile image
Oliver Williams

Its made specifically for hosting static sites, but it can have forms 😮. I hear it also makes working with AWS lamda functions a bit easier, although I haven't tried that yet.
You can use Github, Gitlab or Bitbucket and it will update the site with every merge.
I've personally only used it for single-page HTML websites, but I hear it integrates nicely with static site generators.
And it has a generous free tier :)

Collapse
 
qm3ster profile image
Mihail Malo

So, build your own hugo out of seemingly conveniently shaped pieces?

Collapse
 
gypsydave5 profile image
David Wickes

Yes. Unix programming philosophy at work.

Collapse
 
bayuangora profile image
Bayu Angora

What's about Pandoc's performance speed compared to Hugo?

Collapse
 
gypsydave5 profile image
David Wickes

Good question! Maybe I'll benchmark it - or you could! 😁

Collapse
 
bayuangora profile image
Bayu Angora

Couldn't wait about the benchmark result.

Collapse
 
schoenix profile image
schoenix

I have used the SimpleHTTPServer module of python instead of now for local testing.