Live data from Hacker News

Why You Should Write Your Own Static Site Generator

arne.me

121–130 of 136 posts

Re: Why You Should Write Your Own Static Site Generator

#121
when I made https://carefulwords.com, which is just a thesaurus that I wanted for myself*, I effectively had to make a static site generator, since it required a lot of preprocessing steps to get all the words linked to each other, word synonym lists, and word quotes assembled from various text files. And this article is right: you can just build it. I just put together some TS scripts over a couple weekends to smooth it all together (and then another day on top to make it fast). After that I can keep using and editing my weird bespoke sources to build my project.

If I had to use a static site gen to do the same thing, it probably would have taken a lot longer, or I might have had to do so much pre-processing or massaging of my data that I was effectively building a static site gen on top of someone else's static site gen. And why bother with that? Of course if the project had any more complexity, I would benefit from stronger templating, and putting a static site gen layer after my own static site gen is probably exactly what I'd do. Just stitch them together, instead of trying to get my first-steps into someone else's static site gen.

* I wanted one that has lots of synonyms, has some historic quotes to go with words, has autocomplete and unlike good old thesaurus.com it should focus the text box on load

The result being perfectly static means its perfectly fast. It also means there's a lot of crude overlap - every page has the same HTML copied and pasted a million times. But that's OK, it's small, so it's still faster.

Re: Why You Should Write Your Own Static Site Generator

#122
post #116

Earlier quoted context omitted.

> Off the shelf ones can be cumbersome and not work quite how I want them to. Yeah, that's exactly why I reinvent wheels! I ended up forking an existing templating language and customizing it into a static site generator. I'm not sure what's more difficult: changing other people's code or doing it from scratch.

You forgot 3rd option maybe hardest - just using other people code and understanding it instead of misusing it, calling it crap and going to write ones own broken thing. ;)

I don't think I ever called anyone else's work "crap" though. The software I forked is the pug templating language. It's unmaintained, looks like the author has moved on. Most of my work involved deleting the features I didn't need so that it would be easier to understand and work with. It had a Javascript parser inside it.

But yeah, I get what you mean. It's definitely the hardest thing to do.

Re: Why You Should Write Your Own Static Site Generator

#123
post #102

I made a website that does all the markdown to html conversion right on the client and it still has great SEO. Apparently google and stuff will just index the markdown itself. No compilation step needed.

Yara very interesting! I'm thinking about doing it but was worried about SEO. Doea it load, parse and draw the content fast?

Re: Why You Should Write Your Own Static Site Generator

#124
I had the same idea as you and rewrote my blog CMS. Initially it was very similar to yours, with Maud [1].

Then I started a little library for replacing Maud, for a better developer experience [2] (still looking for a better name).

The important thing for me is having fun in the process, my personal website is a sandbox for playing and experimenting :)

[1] https://anto.pt/articles/rust-server-components

[2] https://github.com/Pitasi/rscx

Re: Why You Should Write Your Own Static Site Generator

#125
I ended up writing my own because nothing did what I wanted (1 post per folder with all media inside the same folder, Wiki linking, partial rebuilds and various layout features). Never looked back, and today I just commit to my source repo and it goes and rebuilds and uploads only the pages that have changed (out of 9000 or so).

Re: Why You Should Write Your Own Static Site Generator

#126
Absolutely agree, I did a fair bit of both and I really regret using the framework du jour.

I have a lot of websites (maybe more than 20) and they're a mix of old version of next.js, hand rolled websites and some solid.js websites.

The solid.js sites are fairly easy to update - but it's also very new (the oldest being 3 years) and I'm not sure it will stay that way forever. You just need one wrong decision from the fun guys at ECMA and frankly I've been burned already by commonjs vs esm.

The handcrafted sites from 10 years ago have some old and simple dependencies and they work fine. The next.js stuff is a horrible nightmare of different errors. Everytime I need to do a one-line change I get to do a nice debugging session. This is also a combination of the providers I'm using not having a fixed node version, but I've also found some dependencies breaking compat from one patch to another.

I guess the key takeaway is: use as little deps as possible.

Re: Why You Should Write Your Own Static Site Generator

#128
post #127

There is also a Static Site Generator written in Python. https://github.com/ahui2016/pyboke . I used this to generate my blog: https://yinan.me

As much as highly visible usages of GPT make me eye roll, I appreciate the up front summaries. It’s particularly well suited to technical blogs.

Re: Why You Should Write Your Own Static Site Generator

#129

Earlier quoted context omitted.

But if you write a static site generator, you can blog about it. And that can be the first and the last post of your blog. If you don't write one, the chance is good, your blog would stay empty.

Why are you personally attacking me like this? In all seriousness does everyone and their mom write a static site generator? I did because its fun and easy. Off the shelf ones can be cumbersome and not work quite how I want them to.

I guess he wrote „you“ in a generic sense.

Re: Why You Should Write Your Own Static Site Generator

#130
I've written my own in (over the years and in order) PHP, Delphi, Ruby, Python, C#, Go, then C# again (after moving from Framework to Core) for serving my blog [1].

- It's fun

- It improves with each iteration due to experience gained

- It's great to have a sample project to create in any language you consider using as it's a small yet realistic way to discover how that language works and what the ecosystem provides

[1] https://kcartlidge.com

As an aside I also quite like yak-shaving - which is why for my latest C# iteration and just for the pleasure of it I've written my own Markdown parser and am working on my own templating engine (bit like Razor, ERB, or PHP).

Post reply on HN