Finish the move to hugo post.
[web-hugo.git] / content / posts / move-to-hugo.md
CommitLineData
7ba37647
JM
1---
2title: "Move to Hugo"
3date: 2022-09-21T20:38:55+03:00
006a830c 4description: "based.quest is now using another static site generator, find out why the change and benefits of it in this writeup."
7ba37647
JM
5tags: ['site','news']
6type: blog
7draft: false
8---
9
10## First of all, why? Wasn't blogit perfect?
11
006a830c
JM
12No, no software ever is perfect. I will give credit where due, blogit is an amazing project that will
13work wonders for kickstarting a new personal blog. However, my ambitions have outgrown *just* a personal
14blog. I strive to make this site for the community (while also maintaining my personal blog) and blogit
15was not going to scale well going forward.
16
17That being said, if you have something to share that you feel like is based (and won't get me in trouble),
18you can clone the new [web-hugo.git](https://git.based.quest/web-hugo.git) repository, create a patch with
19your post and send it my way either via email or Matrix.
20
21## What's going to be different?
22
23Not too much for you, the reader, other than some neat improvements (such as tag and post pagination coming
24in the v0.2 of the Hugo site). The website will still be as light as ever for you to browse, I didn't spoil
25the website with JavaScript or some excess CSS "framework" - I will adhere to these principles that I set out
26when starting this website, I will reject all patches that try to add JavaScript or CSS frameworks.
27
28Behind the scenes, a lot has changed. First, the workflow has changed - back when using blogit, creating a
29page was as simple as using `touch articles/new-post.md`. Once you finished writing the article, you added it
30to the git repository and ran the makefile named "blogit" with target "build". For each build, it had to
31rebuild all the tag index pages, RSS feed, all the posts and the index page which is needlessly wasteful,
32especially given blogit's inefficiency (more on that later).
33
34With Hugo, I open one terminal window to run `hugo server` and another tab to run `hugo create posts/new-post.md`.
35That command creates a new file in the content/posts/ folder using a template (in Hugo world, "archetype").
36I have set it so it automatically fills in the post date and title alongside a few other metadata values
37I use to hint Hugo into building what I want. Do note that you do not *need* Hugo to contribute, you can still
38do it the old way. Once the post is generated, I just edit the post with nano on the same terminal window.
39Once I'm done editing and have saved, instead of having to rebuild the entire website, the earlier ran
40server automatically rebuilds the changed components and live reloads the page in your browser.
41This is a lot more convenient than with blogit and saves a bunch of time when writing posts and wanting to
42preview them as you go.
43
44Secondly, Hugo is a lot more flexible in adding function to the static pages. With blogit I had to go through
45hours of painstakingly editing the Makefile to make it do what I want just barely and even then the result
46was not the best. Hugo gives you flexible templating capabilities from Go, you can familiarise yourself with
47it [here.](https://pkg.go.dev/html/template) So you can expect me to be able to add somewhat more advanced
48features to the site that before I previously had to reject over complexity concerns.
49
50All in all, Hugo makes more sense. It saves time and also performs much better.
51
52## Was it difficult to bring content over?
53Not at all! Since blogit used markdown, the only annoyance was having to redefine preview image and the tags in header
54instead of the footer, otherwise posts ported over fine without any issues. As for how I kept the old URLs valid, I made
55use of [aliases in Hugo](https://gohugo.io/content-management/urls/#aliases). For example on my DeckPC Day-1
56post, I simply added a singl eine to the header: `aliases: ["/deckpc-day-one-experience.html"]`
57
58## How much faster is Hugo then?
59
60A lot. This is 15071 pages (of which 15k are just "sneedx" where x is 1 to 15000) generated in roughly
61the same amount of time as blogit generated my 14 posts on old source.
62```
63(deck@sneed web-hugo)$ time hugo
64Start building sites ...
65hugo v0.92.0+extended linux/amd64 BuildDate=unknown
66
67 | EN
68-------------------+--------
69 Pages | 15071
70 Paginator pages | 0
71 Non-page files | 0
72 Static files | 8
73 Processed images | 0
74 Aliases | 14
75 Sitemaps | 1
76 Cleaned | 0
77
78Total in 3658 ms
79
80real 0m3.741s
81user 0m6.876s
82sys 0m1.562s
83```
84
85Blogit on 14 posts:
86```
87real 0m3.554s
88user 0m2.481s
89sys 0m1.566s
90```
91
92The results speak for themselves. Current site as of writing this post, builds in ~70ms.
93
94## What happens to the old site?
95
96By time you see this post, it's already gone and replaced with the Hugo site.
97Should 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).
98As it stands right now, that repository is archived and won't be accepting any more patches.
99
100Thanks for reading,
101- Cernodile