Previously this was a Wordpress blog running on an ec2 instance. I decided to switch to a static site for a few reasons:
- Cost: Rather than pay to rent a server 24/7, now I’m charged mainly for the microscopic bandwith requirements of my site. It’s really cheap.
- Security: For an unskilled hack of an amateur sysadmin like me, there are risks in running a Wordpress server. I don’t do a good job updating things, so at any given moment I could have unpatched bugs in Wordpress or Apache that were fixed and publicly documented months prior. In comparison, the attack surface of a static site is pretty darn small.
- Efficiency: If my content is static, there’s no sense using electricity to regenerate a page every time it is accessed.
- Scalability: Some might say my readership is, umm, on the small side. Up until now, I’ve run on an ec2 nano instance with no problems. This has been fine and dandy, but it was depressing to know that on the off chance my site did get its 15 minutes of fame, my nano instance would fall flat on its face. Now I’m on S3, which should be able to handle just about any bandwith spike I can imagine, while only charging me for what I need.
The cheapskate in me and the dreamer in me both want the same thing, so I made a change. Enter Hexo, the open source static site generator written in NodeJs.
Hexo installed easily through npm. I cloned an MIT licensed theme, cactus-white, from github, and adapted it to create the exquisite “squirrel-white” theme you see here. The site conversion was done manually, since I only have a few posts. Porting my html to markdown wasn’t too bad, and the yml configs were easy to figure out. I haven’t written any code yet (though I sort of want to, maybe I need to fiddle-fudge the theme some more). After adding 3 lines to the config, I can upload to S3 just by typing
hexo deploy. The only drawback to Hexo I’ve seen so far is that there are some hoops to jump through to with embedding images.
As for S3…like everything on AWS I had to do a shit ton of googling just to complete some pathetically simple task. In order to use a domain name with S3, you have to name your S3 bucket exactly according to the domain, e.g.
brainsquirrels.com. Then, you set your DNS to be an alias for your region’s S3 gateway. You only get one shot at naming; there is no rename option, so don’t waste your time configuring a bucket called
brainsquirrels-com like I did. To do
www.brainsquirrels.comI actually have to create a second S3 bucket which points to the first (I used present tense in that sentence because at the time of writing,
www.brainsquirrels.com doesn’t work).
S3’s learning curve aside, static is awesome. I can’t believe it took me this long to appreciate it, given that it has basically been the default site option since the beginnings of the internet. And of course, 2018’s tools make it easier than ever before.