Take me home

How this blog is made

Written by August Lilleaas, published May 17, 2012

Tl;dr: I use wget and GNU sed to convert a dynamic webapp into static HTML, served by Apache.


You can use this method with any dynamic web app. I happen to have written mine in Clojure, but you can use Rails or Unfiltered or whatever you want, as long as all the content is the same for all visitors to your blog.

This site is served as static generated HTML, much like Jekyll and others. But I don't want to have to write my web page in a specific way just to be able to serve it as static HTML. So I wrote a short script to convert my dynamic web page to static HTML files.

wget -e robots=off -P static -nv -k -p -E -nH -r -l 0 http://localhost:3000
find static -name '*.html' -exec sed -i 's%index.html%%g' {} \;
rsync -zvr --delete static/ augustl.com:www/augustl.com/

This will create a directory structure that is aware of directory indexes on Apache, so /blog/2012/my-post-title/index.html will be the name of the generated files so that Apache serves it when accessed by /blog/2012/my-post-title. wget will link directly to those html files by default, so the sed oneliner removes that part of the links.

The only requirement is that your links have a slash at the end. If not, wget will generate /blog/2012/my-post-title.html, which is not what I want.


Questions or comments?

Feel free to contact me on Twitter, @augustl, or e-mail me at august@augustl.com.