site

A custom static site generator written in C.
git clone https://unitehenry.com/git/site.git
Log | Files | Refs | README

commit 38e089a82cda7a8060edc0404af16648ab6531bc
parent 450990d6e2fa36a501013616fae82d48e778ea24
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sun, 12 Apr 2026 01:37:10 +0000

feat: title tag

Diffstat:
Msrc/generate.c | 9+++++++++
Mtemplates/base.html | 2+-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/generate.c b/src/generate.c @@ -9,6 +9,7 @@ #define BUILD_DIRECTORY "build" #define BASE_TEMPLATE "templates/base.html" #define CONTENT_TAG "{{ content }}" +#define TITLE_TAG "{{ title }}" #define STATIC_DIRECTORY "static" void run_pandoc(FILE **fp, char *content_path) { @@ -242,6 +243,14 @@ void generate_pages(StringList *list) { -1) { fputs(content_line, write_fp); } + } else if (strcmp(trim_whitespace(template_line), TITLE_TAG) == 0) { + if (string_map_contains(metadata, "title")) { + char *title_tag; + + asprintf(&title_tag, "<title>%s</title>", string_map_get(metadata, "title")); + + fputs(title_tag, write_fp); + } } else { fputs(template_line, write_fp); } diff --git a/templates/base.html b/templates/base.html @@ -3,7 +3,7 @@ <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Page Title</title> + {{ title }} <link rel="stylesheet" href="css/style.css" /> </head>