Live data from Hacker News

Rewriting my blog in Rust for fun and profit

jonashietala.se

81–90 of 116 posts

Re: Rewriting my blog in Rust for fun and profit

#81
post #7

I've been trying to make a cool static site generator numerous times. Well, yes, it actually is a quite fun thing to tinker with, but I've found myself struggling to decide on what do I want to see in the final app and what I do not; what features might be needed by other users and what features might be an overkill. So I ultimately went with Zola[1] and encourage you to try it too! Aaaand it is written in Rust, too.…

I did this as my project to learn Rust, to build with all the features needed for a good static site generator was a great way to learn!

I still haven't released it as there are some bugs (localization!) that i need to fix but if you want to have a play the staging site is here[1].

[1] https://stage.uwe.app/

Re: Rewriting my blog in Rust for fun and profit

#82

This is mindblowing synchronicity. I thought this article was one I had read this weekend for a second but checked the post date and saw it wasn't available yesterday. I'm working on trying to write a static site generator for my own personal site/blog in C++, been tinkering for a couple months. It started as a passion project in tribute to my dog that passed. GatsbyJS wasn't working (again) which is what my current…

I've found you don't actually need a templating system, you just need format-strings. Write your rendering logic with normal code that just spits out a string Templating languages probably help with performance a bit when you're rendering at request-time, but for static stuff I don't really see much point I've got a hand-rolled static site generator in JavaScript that just uses template strings. I only have around 30…

One great benefit of a good template language is automatic escaping (e.g. within HTML attributes or tags), which you won't get from format strings.

Re: Rewriting my blog in Rust for fun and profit

#84
For my own blogging needs, I chose an even more pragmatic alternative to markdown - email!

Well, email is a actually a single file CMS which contains html, plaintext, attachments/images, and metadata like when the email was sent and the subject line,

With all this, it turns out you can create pretty nice looking webpages without having to futz around with md->html conversions.

The huge advantage is that since I know gmail, whenever I have an idea for a blog post, I can go from idea to published in minutes. The biggest time suck tends to be finding stock photos for the post.

As far as tech stack goes, it’s all serverless. I use SES to handle inbound emails and the excellent nodemailer package to parse .eml files.

Re: Rewriting my blog in Rust for fun and profit

#85

Earlier quoted context omitted.

I've found you don't actually need a templating system, you just need format-strings. Write your rendering logic with normal code that just spits out a string Templating languages probably help with performance a bit when you're rendering at request-time, but for static stuff I don't really see much point I've got a hand-rolled static site generator in JavaScript that just uses template strings. I only have around 30…

One great benefit of a good template language is automatic escaping (e.g. within HTML attributes or tags), which you won't get from format strings.

Is that important in a static site generator?

In a server-rendered site you have to worry about injection attacks, but that's not really relevant when you're statically generating a site from content that's fully under your control

Re: Rewriting my blog in Rust for fun and profit

#86
post #58
post #7

I've been trying to make a cool static site generator numerous times. Well, yes, it actually is a quite fun thing to tinker with, but I've found myself struggling to decide on what do I want to see in the final app and what I do not; what features might be needed by other users and what features might be an overkill. So I ultimately went with Zola[1] and encourage you to try it too! Aaaand it is written in Rust, too.…

> I've found myself struggling to decide on what do I want to see in the final app and what I do not; what features might be needed by other users and what features might be an overkill. It's tricky. You can't accept all the features otherwise you just have a mess. At the same time you need to also add/supports features that a lot of people want but _you_ personally don't need if you want the tool to be used by more…

Storing the internal state in sqlite and allowing Lua plugins to operate on it might be a way of extending things.

Re: Rewriting my blog in Rust for fun and profit

#87
My recommendation for people using anything like Jekyll: just bite the bullet and write a custom build script. A 200 line script that takes can handle Jinja templates or markdown or something will mean you actually understand all that is happening and aren't trying to fight the system or just figure out how to do anything.

And of course don't write a plugin system or something you would share with others! Just write the thing that you need, and change it as you need to!

Static site generators are great for people less comfortable doing this, but having to deal with all the _stuff_ is a major waste of time for what it's offering for people who don't need it.

Re: Rewriting my blog in Rust for fun and profit

#88
post #87

My recommendation for people using anything like Jekyll: just bite the bullet and write a custom build script. A 200 line script that takes can handle Jinja templates or markdown or something will mean you actually understand all that is happening and aren't trying to fight the system or just figure out how to do anything. And of course don't write a plugin system or something you would share with others! Just write…

I have the opposite advice: optimize for writing, minimize janitorial stuff like tweaking your own tooling. It just distracts you from writing and offers only masturbatory value.

The best path depends on your personality, but building my own blog tooling killed my writing. I'd start writing something only to realize I needed to tweak something. Then I wouldn't even write the post or I wouldn't have the energy to fix the tooling and I'd do neither. And then I stopped writing.

I didn't start writing again until I used Wordpress which let me focus on writing, though after proving myself for a year, I switched to Jekyll + Github Pages so that everything was on Github.

Re: Rewriting my blog in Rust for fun and profit

#89
post #87

My recommendation for people using anything like Jekyll: just bite the bullet and write a custom build script. A 200 line script that takes can handle Jinja templates or markdown or something will mean you actually understand all that is happening and aren't trying to fight the system or just figure out how to do anything. And of course don't write a plugin system or something you would share with others! Just write…

100% agreed. The things a static site generator does are typically very simple: load some Markdown into memory, run it through some HTML templates, and maybe scale some pictures with ImageMagick if you're feeling especially fancy. Writing a script to do those things is way easier than trying to learn and wrangle a Static Site Generator(tm).

The one time static stie generators are helpful is if you really, really like the out-of-the-box look and behavior of some existing theme.

Re: Rewriting my blog in Rust for fun and profit

#90
post #87

My recommendation for people using anything like Jekyll: just bite the bullet and write a custom build script. A 200 line script that takes can handle Jinja templates or markdown or something will mean you actually understand all that is happening and aren't trying to fight the system or just figure out how to do anything. And of course don't write a plugin system or something you would share with others! Just write…

100% agreed. The things a static site generator does are typically very simple: load some Markdown into memory, run it through some HTML templates, and maybe scale some pictures with ImageMagick if you're feeling especially fancy. Writing a script to do those things is way easier than trying to learn and wrangle a Static Site Generator(tm). The one time static stie generators are helpful is if you really, really like…

To this point: Markdown is a nice format for ingest because you can just paste in HTML. I am a bit more courageous and have some custom directives for my Markdown stuff, but it's all really 20 lines of code.

I think it's tempting to add a bunch of "time saving" features for writing, but lots of time just going with the HTML is fine. Maybe if you're writing out a post every couple of days then you can focus on time saves. Until then MD will get you most of the way, and otherwise you can always hack in some special case for your unique post

Post reply on HN