Handling Static Assets In Nanoc

December 26th, 2009

Nanoc has no built-in way of handling static output. (Things like CSS files, images, etc.) In fact, when you run the nanoc3 create_site command, it inserts a style.css in the output directory. If you delete the output directory, running nanoc3 compile will not put the style.css file back in the output directory.

This is clearly (to a programmer) unsatisfactory. I want the output directory to be completely rebuilt (if necessary) every time I run the compile command. Having permanent files, such as style.css and images, mixed in with the generated HTML files offends my sense of decency.

This is not yet built into nanoc, but it’s something the author of nanoc is working on. Parsing the mailing list, it looks like static asset handling was built into version 2 of nanoc, but has not yet made it into version 3. It’s destined for version 3.1 of nanoc.

There is, however, a workaround to get this behavior now. However, with a few minutes of work I was unable to get the Rake tasks function properly. This is undoubtedly due to my complete unfamiliarity with Ruby and Rake. (And also to the fact that version 3.0.2 of nanoc does not appear to match the docs.)

Instead, I’m going edit my existing publication script to add a simple rsync statement, as I’m already very familar with rsync.

Now my assets are being copied from ./schof.org/assets to ./schof.org/output, and the same rsync statement I was already using is copying everyting from ./schof.org/output to the public www directory.