blob: e2a8df1982c03b204b8d9edb053fb6e9419ab784 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
---
title: Writing a static site generator for fun and profit
date: 24/3/26
---
Tired of bloated Next.js projects taking up 100MBs of RAM on my VPS, I decided
to shift my personal site to a more minimal framework. Remembering [Luke
Smith](https://www.youtube.com/@LukeSmithxyz)'s old video about Hugo, I decided
to give it a try. I was thinking of writing my own Hugo Theme when I had the
"bright" idea of writing my very own static site generator instead.
> Enter **Kite**
## How an SSG works
A static site generator takes in a directory full of markdown files and
converts them plain-old HTML files while maintaining a theme. For my use-case,
since I mainly wanted a blog, the most important page would be the **post**
page.
The Page struct can therefore be defined as:
```go
type Page struct {
Title string
Content template.HTML
TOC []TOCItem
}
```
## Parsing Frontmatter
Frontmatter is the small YAML-like block at the top of each markdown file
containing info such as the post title, it's date, tags etc.
```go
type Frontmatter struct {
Title string `yaml:"title"`
Date string `yaml:"date"`
Tags []string `yaml:"tags"`
}
```
|