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