Live data from Hacker News

Why You Should Write Your Own Static Site Generator

arne.me

21–30 of 136 posts

Re: Why You Should Write Your Own Static Site Generator

#21

It's a fun project to try out new tech, but you have to acknowledge that you're doing it for fun rather than any sort of necessary reason. It's like when you build a game engine and never get around to doing the hard part: building the game. It's a procrastination time hole that mostly just distracts us from the harder, less concrete, less fun thing we supposedly set out to do in the first place. It keeps us from shi…

Fun, learning something new, unlocking additional productivity in authoring posts from a customizable templating engine... I can easily convince myself of necessary reasons ;D

Re: Why You Should Write Your Own Static Site Generator

#23
I've written two static site generators... well one of them has a full blown UI (drag and drop, side panels etc), the other is a command line tool.

For the WYSIWYG tool I used craftjs and lexical, and ran into issues with both - bugs, difficulty doing things like having different alignment for mobile vs desktop. It was very brittle and it would be troublesome migrating data structures down the track. I've put 1.5 years into this (added my own k8s hosting on GCP too - also with its issues)!

The second command line builder took me a couple weeks to make a simple version of. I describe my pages, sections in JSON and render predefined erb templates. I scripted up deployment to Amazon S3, Cloudfront, and invalidate the cache after deployments.

It's crazy I spent so long on the Saas version and didn't get to a working website, and with the command line version now have a couple sites up!

It's a cool experience to make your own site builder, definitely learn something each time you do.

Here are the sites I made:

https://www.madebyhelena.com https://LouisSayers.com

(Helena is my partner, I remade her site which she had created on a different platform)

Re: Why You Should Write Your Own Static Site Generator

#24

> Plus, you get to choose your own stack. Want to write your content in AsciiDoc? No-one can stop you! I wrote a static site generator once. I used a Makefile and m4 macros! Yes, it's true: nobody could stop me. It's much more debatable whether the "you should" part applies. I was just trying to get some common header and footer HTML into all pages of a site and do it with tools that were already installed on the hos…

> For some reason, the person who took over the site after me did not follow in my footsteps and keep using m4.

Shame...

Anyway, my first and only SSG was based on Atom for storage, PHP for backend and XSL for client side rendering.

We called this flat file CMS which was the style at the time and...

Re: Why You Should Write Your Own Static Site Generator

#25
I agree.

I don't mean to say you should not share it. You constructed something good, you feel pride in your device, by all means share it with the world.

However static site generation is one of those simple fun rewarding types of program to make. The programing is straight forward, the results are linear with the input, that is, there is not a huge amount of boiler plate you have to wade through to see anything. Basic batch data transformation like this is the perfect environment to metaphorically "putter around in the workshop"

Nothing wrong with using someone else's, but really, you should write your own.

Re: Why You Should Write Your Own Static Site Generator

#26
post #4

I've never understood the point of these things. Just use a solid CMS and cache to s3 or Varnish. What's the big deal?

No maintenance.

When I had a dynamic blog (DB backend, etc), I got hacked because I wasn't updating the SW often. Not having to worry about things like that is a significant quality of life difference. I want to run my life, not have my tools run them.

But frankly, let's invert the question. What exactly is the benefit of using a CMS vs an SSG like Pelican? After having used the latter for over a decade, it's dead simple. Open a file. Write your content. Run make. And publish. It's trivial to back up. I don't have to know what a cache is. I don't have to keep updating SW. What is the actual benefit of a CMS for a single user like me?

Re: Why You Should Write Your Own Static Site Generator

#27

Did an SSG last month. I had used pelican before; but I wanted to get a better handle on using Markdown and Jinja libraries "from the other side" as well. I would have needed to adapt my file structure or write some code to let pelican scan my idiosyncratic hierarchy to generate the posts. Turns out Markdown is easier to use on your own scripts, than it is to tweak its configuration in pelican; and Jinja is quite sim…

I know people write SSGs because of frustration with their existing one, but did you consider writing a tool that "publishes" to Pelican? That's kind of what I do: I write all my posts in a single org file, and have Emacs process them and output rst files for Pelican's consumption.

Re: Why You Should Write Your Own Static Site Generator

#28
post #5
post #4

I've never understood the point of these things. Just use a solid CMS and cache to s3 or Varnish. What's the big deal?

The deal is that a lot of static site generators are very complicated (perhaps needlessly so), despite the fact that static sites are technically very simple. Perhaps some people really leverage the power of Next.js, but when I tried it, I felt that it was super heavyweight when I just needed to template html files. Of course, that doesn't mean I need to write my own. I just used a simpler SSG. In my case Jekyll.

NextJS is far more than an SSG; it's a general-purpose Java/Typescript app development framework for frontends and backends.

Re: Why You Should Write Your Own Static Site Generator

#29
I recently had to nuke the Linux environment where I had my Jekyll environment finely tuned (Ran it on Debian WSL). Then I realised I had to reinstall Ruby, but the current Jekyll version (or the gems I use) uses a version that needs to lock OpenSSL at a certain version because of some breaking changes. Tried to lock the version in Debian and I was having a really hard time.

Then I realised I just could grab the latest Jekyll image from Docker hub and build my website with it. And just like that I was able to build my website without dealing with any ridiculous dependency.

So yes, you should write your own static site generator because it might be a tad easier than trying to install from scratch the dependencies of whatever generator you have chosen.

Post reply on HN