Jan 9, 2019
Why and how'd you build this?
I wanted to write a quick post to go over how this blog is structured and what it's origin story was.
I wanted a blog that could:
- Be a stream of photos I'd taken.
- Resize the photos from the originals to thumbnail sizes.
- Be statically hosted on S3, and fronted with CloudFront.
- Extract and structure EXIF data.
- Use SSL.
- Occasionally handle a text post or two.
- Draw clear abstractions between what was provided by the tool (data) and the blog's own code (formatting).
- Leverage golang templates to some degree, as they're something I'm familiar with.
Originally I used the fantastic hugo, but I ran into a bunch of limitations, namely how it handled images and not being able to generate thumbnails easily.
So I ended up writing a tool called blogctl. The name is a combination of
control, in the same vein as
kubectl(something I use every day).
One key consideration with this is the tool itself provides very specific things in producing the final output; it enumerates the posts, renders given templates (some for each post), copies the files to S3 and invalidates the Cloudfront caches. It does not have any coupling to how the blog will eventually look or function, that is left to the individual implementations of blogs (very much like how hugo works).
The code for this blog is in a separate repo, charczuk.com, which includes all the post templates, static files like css, and the posted images themselves.
The result is a pretty expressive way to build the blog, as I can play around with how it's formatted and the tool just processes the post data, golang templates handle the rest. Also, because it's hosted statically I don't have to worry about runtime components or scale problems.
If you'd like to get started messing around with it, there are a couple helper commands (namely
blogctl init) that will help you get started and create a shell blog for you.