Live data from Hacker News

Why You Should Write Your Own Static Site Generator

arne.me

111–120 of 136 posts

Re: Why You Should Write Your Own Static Site Generator

#111
I fully support the idea that writing your own SSG can be not only a great learning experience, but also a chance to make your SSG do exactly what you want it to (and nothing more).

I've written a ton of little SSGs over the years, and every iteration I've learned what kind of features I really need, and which I don't.

When I started working on the current version of my personal website (istigkeit.xyz), I also wrote a new SSG just for it. The program is called Hyphae[1], and it's written in Ruby using the Kramdown markdown gem, and pretty much nothing else outside the stdlib. It works perfectly for me, and that's all that matters (that being said, the code is up there, and licensed with the Unlicense, so anyone who finds it useful is free to use and abuse my clumsy code to whatever extent they want).

I'm a big proponent in the idea of writing personal software: that is, programs that are made by you, for you, and with no expectation that they'll be used by anyone else. I think too often developers these days get caught up in trying to make their project be "the next big thing" in whatever domain it serves, but honestly sometimes it's nice to just write something for yourself :)

[1]: https://gitlab.com/henrystanley/hyphae

Re: Why You Should Write Your Own Static Site Generator

#112
post #39

I've been very impressed with Eleventy: https://www.11ty.dev/ I find my lingering desire to roll out an SSG slowly fading.

Hadn't heard of Eleventy, I thought Zola was where you went for speed, which they don't even bother comparing too. Found this post comparing them & more, Eleventy (man that's annoying to type on mobile with autocorrect though!) for speed it says. https://mtm.dev/static

Love the build times, thats for sure.

I'm really attracted to the Eleventy approach on the whole - there's no bloat, they don't inject any of their own js, I can move fast and only add complexity where I actually need it.

Re: Why You Should Write Your Own Static Site Generator

#113

Just like a bunch of us here, I also wrote an SSG. I setup a cronjob to fetch weather data and run the SSG to parse the XML and render a weather "website" on my VPS. But for the blogs I've had/have, I just use a pre-existing one (zola). There are hundreds of SSGs out there, why bother building yet another one if one already exists for transforming your preferred base doc (markdown, asciidoc, morse code, etc)

The most commonly missing SSG feature for me is being able to transform relative links between Markdown files (which VS Code happily auto-completes for me) into relative links between the resulting HTML files.

Similarly hard to find is tagging posts based on file system metadata (e.g. everything in “posts/linux/“ should be tagged with “linux”).

Re: Why You Should Write Your Own Static Site Generator

#114

I didn't realize this was so common. In my crazy days I wrote a SSG using only XSLT, so you wrote a big xml with the content and it would output a full site ready to upload. It needed a specific XSLT processor as most couldn't generate individual files, but it was nice that it worked with off the shelf software, so technically I didn't write a single line of code. (XSLT is madness, don't attempt)

I also did this, except the XML file itself was generated from a file system tree.

XSL did eventually add multiple outputs, but yeah: do not attempt :)

Re: Why You Should Write Your Own Static Site Generator

#115

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.

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.

Guilty as charged, many times over. Sometimes, to the point where I could not even recall the old workflow post login.

Re: Why You Should Write Your Own Static Site Generator

#116

Earlier quoted context omitted.

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.

> 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. ;)

Re: Why You Should Write Your Own Static Site Generator

#117
post #37

Call me crazy, but for my blog I just write HTML and RSS manually in a text editor.

I do the same, but after a while I got fed up with the tedium of hand-managing the metadata and all the duplication that happens if you add OpenGraph, Twitter and Dublin Core.

So I wound up storing the basic metadata in a JSON file, then I assemble the header and footer of the page with PHP, which is then rendered out to a complete HTML page.

It's not quite a SSG, but just a little help automating the boring stuff.

Re: Why You Should Write Your Own Static Site Generator

#119
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.

This is the perfect summary all the setups people have, with lots of "wow, I feel personally attacked" included: https://rakhim.org/honestly-undefined/19/

Re: Why You Should Write Your Own Static Site Generator

#120
I think the answer depends what kind of site you are targeting. For a clean and simple text blog it may actually be optimal to build something from scratch using building blocks you know well.

But for a larger site that might evolve and get more complex over time the DIY approach will likely hit the reinventing-the-wheel dilemma multiple times.

Its better to figure out which of the existing SSG's has a programming model that fits your brain and simply learn it well so that you can extend it in any which way you like.

As a bonus, instead of yet another half baked ssg, you can contribute something back in terms of plugins, themes or other code and feel good about yourself.

Post reply on HN