Back to home

Private Files on a Static, Open-Source Website

This site is pretty simple. It's completely static, and serves no Javascript whatsoever. I write each and every page in raw HTML (with a drop of CSS here and there) using Vim. It does not rely on content from other sites—every resource it loads is contained in its public Github repo. I use this site to publish short articles or other pieces of writing, some of which take weeks to write. Given all this, it is not obvious where I should store my drafts and works-in-progress for writing that will eventually be published on this site. I would like them to be stored in pretty much the same place as the published writing on my machine, so that they can render in pretty much the same environment as they will once published. For convenience, I would also like them to be stored in the same Git repo as the published work, but they should not be publicly visible.

To reconcile these seemingly contradictory requirements, I decided to store my works-in-progress, and other site files meant to temporarily be kept private, in a single encrypted archive (called private.tar.gz.gpg) in the public repo. I wrote the Bash script priv.sh[1] to manage this archive. The workflow looks something like this:

This makes the writing process pretty convenient. I just edit the prefixed files, and when I'm ready to publish them, I take away the prefix. To save and back up my work, I only need to periodically run priv.sh zip and commit the private.tar.gz.gpg file to the site's repo. If I want to keep working from a new machine, or look through previous versions of my works-in-progress, or restore work that was somehow lost, I can do so with most of the ordinary convenience of Git and Github.

If you're interested in the implementation details, take a look at the script itself.[1] It's commented up quite a bit.

Notes

back [1]: This is a snapshot of the priv.sh file from the time this article was published. You can check out the current version live on this site here, or on Github here