How I Rebuilt my Website with Rust
And how you can build your own blog! // dvub
Why? | Inspiration
There were a lot of factors that influenced me in building out this project. Most recently, after getting tired out
by some other projects (which I should definitely write about soon), I wanted to start something new. Lately I feel
like I've been on a Rust roll (and rightly so, because Rust is awesome), so I decided to revisit web development,
but with a Rust-based stack.
For a while now, I've wanted to redesign my personal website to be
simpler, not only in terms of the UI/UX,
but also (and more importantly
for me) the DX. I created the first iteration of my personal website nearly 2
years ago in Next.js, and although it was fun, there was a lot of hassle and complexity involved (a lot of it was
probably due to my inexperience as a developer, but we'll ignore that).
Another influence in my decision to recreate my website was, well, influencers - specifically software
streamers/YouTubers - talking about these hype, new, JS-less web dev stacks - like Go + HTMX, etc. - My impersonable
self would have jumped right on that train
if I knew Go, but, well, I don't. I do, however, know an even
better language:
Rust! I've been learning Rust for maybe 2 years now, and although I'm still very much a
beginner, I'm definitely improving.
How? | The Stack
Here it is, the moment you've been waiting for, the sauce, the magic, the stack (drumroll, please!): Rust + Axum
+ Tera + HTML ( + Tailwind I guess). Let me break that down a bit.
-
Rust & Axum
As I've (sort of) mentioned before, I just kinda like Rust! As for axum, though, I chose it because it's one
of the most popular web frameworks, and I want to go with something stable and production-ready.
-
Tera (And not Askama?)
While I was doing research for this project, I was originally going to use Askama.
However, I wanted to just have one handler/route for all of my posts, and Askama can't really do that.
So, while I am trading off some type safety for Tera, my code won't be filled with a ton of empty structs for
each post I want to write.
-
HTML?? (NOT HTMX???)
Yes, well, at least at the time of me writing this. HTMX is largely meant for
communicating with your server, for example when submitting a form, etc. But this site doesn't really have a lot
of that! It's just a bunch of text and some styling. Maybe if I added a comment feature on my posts, I would
have a use case for HTMX, but for now, plain Ol' HTML will do.
-
Tailwind!
Honestly, I don't know if I can go back to plain CSS after using Tailwind.
I can put a design idea into code at blazing speeds.
DX | Worth it?
As I mentioned before, I wanted to rebuild my website (without JS) for the improved development experience. So, how
much better is it?
Right now, it's probably too early to say. But, considering that it only took me a few days to draft the
backend architecture, styling, and a first post, I think that's really amazing.
Furthermore, considering that for the past 2 years, almost all of my web endeavours have involved React, building
this project has been
a deep breath of fresh air. That's not to say that React is bad, of course.
Credit
I'd like to finish this up by linking some awesome repositories that I drew a lot of inspiration (and code) from:
Diving into a new stack was challenging at first, and I definitely couldn't have done it without these awesome
examples.