Live data from Hacker News

Why You Should Write Your Own Static Site Generator

arne.me

81–90 of 136 posts

Re: Why You Should Write Your Own Static Site Generator

#81

I know what you're thinking and you're right, it's way more work than using something that already exists. But it's also so much more fun. You can do anything with this, and you don't need to read documentation or try to understand other people's architectural decisions—just start writing code! Great argument for never writing your own SSG. Back in the day we didn't have SSG's. We just wrote the html/js/css by hand,…

I maintain a web site for a small club I'm in. I use an existing SSG (Zola). My goal is that people can get information about when the club meets, about our events, etc.

I do not care about how "fun" it is to maintain, I care if people can get the information they need. It should take as little effort as possible, because extra effort maintaining the site has to be taken from something more valuable I could do with my time.

Re: Why You Should Write Your Own Static Site Generator

#83
This is so cool. I did the same last week with pure php without any dependencies besides icon, gd and rsync for deployment. Feels like I had sitting inside a LAMP prison for the last two decades. Now just some json files are my database. No fancy bullshit. Just handmade code and some templating. I feel freed like you.

Re: Why You Should Write Your Own Static Site Generator

#84
I use a hybrid approach. Next.js is the base for my site but I use next-sitemap and a hand rolled content compiler (md -> html -> jsx) for feeds, meta tags, and generating every page I dont manually specify as a .tsx file.

I like having the flexibility to do either. Complete control in .tsx or just writing in .md. I would like to add .mdx eventually too

Re: Why You Should Write Your Own Static Site Generator

#85
post #20

I'm not sure I'd advocate for writing a static site generator, although I'm certainly guilty of writing a few myself. Instead I always encourage people who are trying to start blogging to do the writing first. Figure out a workflow that works for you - what time of day you prefer writing, what editor, do diagrams naturally come up in your thought stream, etc. It's way easier to get this workflow dialed in when you're…

Also guilty of writing a few SSGs and blogging about them. Proud to share that now I rsync my half baked writing directly to prod!! No build step!

Re: Why You Should Write Your Own Static Site Generator

#86
Considering that a vast majority of people who decide to learn a static site generator never end up really developing their static site much beyond a few articles talking about their static site generation process, I think there is definitely more value in just going all the way and writing your own static site generator from scratch. The code is the true purpose, not the final output. And the thing about a static site generator is, once it works – you’re done. You can put the project away and move on to other common things like building a tile map editor, etc.

Re: Why You Should Write Your Own Static Site Generator

#87
Another option that I’ve found worthwhile is to write a Jekyll Plugin, so you get a stable base for your SSG, and you can experiment with adding weird functionality on top.

For my news website, I needed to scrape some news from a third party API, and I just moved it to a Jekyll plugin so it embeds neatly into the website. Works quite well: https://github.com/captn3m0/news

Another place where it made sense to use SQLite as a data source, I wrote a Jekyll SQLite plugin.

Re: Why You Should Write Your Own Static Site Generator

#88
post #20

I'm not sure I'd advocate for writing a static site generator, although I'm certainly guilty of writing a few myself. Instead I always encourage people who are trying to start blogging to do the writing first. Figure out a workflow that works for you - what time of day you prefer writing, what editor, do diagrams naturally come up in your thought stream, etc. It's way easier to get this workflow dialed in when you're…

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.

Also, every 2 years post "I've neglected my blog for a long time, but that's about to change now!" ... and then another 2 year silence.

Re: Why You Should Write Your Own Static Site Generator

#89

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 made one for a single page that I wanted to template nicely without introducing dynamic pages (wasteful since it's always the same file anyway) or JavaScript (wasteful since the layout is always the same anyway)

I'll probably do another one again soon, just so I don't have to rewrite my HTML / RSS by hand to publish another post.

Lua is a nice data language, so I just put the data and the code and the HTML fragments into one Lua file, no more than 200 lines. No worries about injection since it's all my data with no backend code at runtime.

Post reply on HN