No description
This repository has been archived on 2026-10-16. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Zig 90.5%
  • HTML 5.9%
  • Makefile 3.3%
  • CSS 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-15 16:11:00 +03:00
src Safety guaranteed by removing some try keywords. 2026-10-15 16:11:00 +03:00
.gitignore Switched from pure flake to devenv + flake 2026-08-14 21:15:00 +03:00
build.zig Change from arena to gpa allocator 2026-10-14 15:30:57 +03:00
build.zig.zon Change from arena to gpa allocator 2026-10-14 15:30:57 +03:00
LICENSE License 2026-08-22 03:30:16 +03:00
Makefile ocd 2026-10-14 15:59:52 +03:00
README.md Change from arena to gpa allocator 2026-10-14 15:30:57 +03:00

Zettp

Zettp is a zig written, extensible and easibly hackable http server and templating system that eliminates all javascript bloat from webservers.
Zig version: 0.17.0

Why?

I don't particularly like javascript/typescript stacks and I was in need of a fun side project :) I also do think that running the entire modern internet on top of nodejs servers wastes an enormous amount of resources.

Usage

To add a new site to the zettp, create two files in the src/html/ folder.

  • page.html
  • page.zig

or if you dont need templating, you can just add sites to src/html/public to serve them statically.

The page.zig file will include some boilerplate, data members for the file and what html file to read. A great example on how to construct a page, can be found from src/html/index.zig and src/html/index.html

After that, you need to add a route to your src/html/server.zig In there you also handle configuration of the server.

main.zig and actions.zig are just wiring and helper functions. Though you can change the memory allocator from main.zig.

Any static files should be placed in src/html/public for example, your favicon, or stylesheet files.

Static Site Generation

For static site generator, you can use zettp-kani, a static site generator made with C
https://codeberg.org/Katacc/zettp-kani There is make step for it :)

Compiling and running

NOW RECOMMENDED TO USE ZIG BUILD SYSTEM:

zig build -Doptimize=ReleaseSmall
./zig-out/bin/zettp

To compile the software, change the flags and options in Makefile to match what you want, and run:

make clean
make build
make run

# or cr for clean build run
make cr 

Features

Because zettp is written in Zig without any external dependencies, it is really easy to hack it. Therefore there is not really any set features. It provides basic building blocks for making templated websites, but you can implement and extend anything you need.

Of course normal html and css stuff works. But in addition Zettp provides you a templating engine. You can do 'directives' inside your html code. For example if you have a list of people in index.zig

names: []const []const u8 = &.{"Katacc", "Meow", "Nya"},

you can use the names variable in your html file.

To check if names is not empty and then iterate over names and print each name

    <button>Click here if cool</button>
    %%
    if (names) {
        for (names) |name| {
            <p>${name}</p>
        }
    } else {
        <p>No people :(</p>
    }
    %%
    <p>meow!</p>

Added the button and p meow in the example to show how the inlining works.

Why makefile instead of zig build tools?

Well, I don't like the zig build tools.