From 006a830c18600e64a233c42c7ed9adaa6f28e46a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joann=20M=C3=B5ndresku?= Date: Wed, 21 Sep 2022 22:53:38 +0300 Subject: [PATCH] Finish the move to hugo post. --- content/posts/move-to-hugo.md | 92 ++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/content/posts/move-to-hugo.md b/content/posts/move-to-hugo.md index 96b00ab..9929e4e 100644 --- a/content/posts/move-to-hugo.md +++ b/content/posts/move-to-hugo.md @@ -1,7 +1,7 @@ --- title: "Move to Hugo" date: 2022-09-21T20:38:55+03:00 -description: "" +description: "based.quest is now using another static site generator, find out why the change and benefits of it in this writeup." tags: ['site','news'] type: blog draft: false @@ -9,3 +9,93 @@ draft: false ## First of all, why? Wasn't blogit perfect? +No, no software ever is perfect. I will give credit where due, blogit is an amazing project that will +work wonders for kickstarting a new personal blog. However, my ambitions have outgrown *just* a personal +blog. I strive to make this site for the community (while also maintaining my personal blog) and blogit +was not going to scale well going forward. + +That being said, if you have something to share that you feel like is based (and won't get me in trouble), +you can clone the new [web-hugo.git](https://git.based.quest/web-hugo.git) repository, create a patch with +your post and send it my way either via email or Matrix. + +## What's going to be different? + +Not too much for you, the reader, other than some neat improvements (such as tag and post pagination coming +in the v0.2 of the Hugo site). The website will still be as light as ever for you to browse, I didn't spoil +the website with JavaScript or some excess CSS "framework" - I will adhere to these principles that I set out +when starting this website, I will reject all patches that try to add JavaScript or CSS frameworks. + +Behind the scenes, a lot has changed. First, the workflow has changed - back when using blogit, creating a +page was as simple as using `touch articles/new-post.md`. Once you finished writing the article, you added it +to the git repository and ran the makefile named "blogit" with target "build". For each build, it had to +rebuild all the tag index pages, RSS feed, all the posts and the index page which is needlessly wasteful, +especially given blogit's inefficiency (more on that later). + +With Hugo, I open one terminal window to run `hugo server` and another tab to run `hugo create posts/new-post.md`. +That command creates a new file in the content/posts/ folder using a template (in Hugo world, "archetype"). +I have set it so it automatically fills in the post date and title alongside a few other metadata values +I use to hint Hugo into building what I want. Do note that you do not *need* Hugo to contribute, you can still +do it the old way. Once the post is generated, I just edit the post with nano on the same terminal window. +Once I'm done editing and have saved, instead of having to rebuild the entire website, the earlier ran +server automatically rebuilds the changed components and live reloads the page in your browser. +This is a lot more convenient than with blogit and saves a bunch of time when writing posts and wanting to +preview them as you go. + +Secondly, Hugo is a lot more flexible in adding function to the static pages. With blogit I had to go through +hours of painstakingly editing the Makefile to make it do what I want just barely and even then the result +was not the best. Hugo gives you flexible templating capabilities from Go, you can familiarise yourself with +it [here.](https://pkg.go.dev/html/template) So you can expect me to be able to add somewhat more advanced +features to the site that before I previously had to reject over complexity concerns. + +All in all, Hugo makes more sense. It saves time and also performs much better. + +## Was it difficult to bring content over? +Not at all! Since blogit used markdown, the only annoyance was having to redefine preview image and the tags in header +instead of the footer, otherwise posts ported over fine without any issues. As for how I kept the old URLs valid, I made +use of [aliases in Hugo](https://gohugo.io/content-management/urls/#aliases). For example on my DeckPC Day-1 +post, I simply added a singl eine to the header: `aliases: ["/deckpc-day-one-experience.html"]` + +## How much faster is Hugo then? + +A lot. This is 15071 pages (of which 15k are just "sneedx" where x is 1 to 15000) generated in roughly +the same amount of time as blogit generated my 14 posts on old source. +``` +(deck@sneed web-hugo)$ time hugo +Start building sites ... +hugo v0.92.0+extended linux/amd64 BuildDate=unknown + + | EN +-------------------+-------- + Pages | 15071 + Paginator pages | 0 + Non-page files | 0 + Static files | 8 + Processed images | 0 + Aliases | 14 + Sitemaps | 1 + Cleaned | 0 + +Total in 3658 ms + +real 0m3.741s +user 0m6.876s +sys 0m1.562s +``` + +Blogit on 14 posts: +``` +real 0m3.554s +user 0m2.481s +sys 0m1.566s +``` + +The results speak for themselves. Current site as of writing this post, builds in ~70ms. + +## What happens to the old site? + +By time you see this post, it's already gone and replaced with the Hugo site. +Should you wish to still make a copy of it, I have moved its repository to [web-old.git](https://git.based.quest/web-old.git). +As it stands right now, that repository is archived and won't be accepting any more patches. + +Thanks for reading, +- Cernodile -- 2.25.1