CAX Documentation

Complete guide for CAX - Blazing fast Static Site Generator in pure C

CAX Documentation

CAX Documentation

CAX is a blazing fast Static Site Generator written in pure C. Inspired by Eleventy 11ty, built for speed.

Installation

git clone https://github.com/mesinkasir/cax-minimalis
cd cax-minimalis
mingw32-make

Commands

CommandDescription
cax initInitialize project structure
cax buildBuild production site to site/ - clean, no live.js
cax serveServe production preview at http://localhost:8080
cax startDev mode - Serve + Watch + Live Reload
cax watchAlias of start

Project Structure

.
├── content/          ## Markdown content
│   ├── index.md
│   ├── about.md
│   └── posts/        ## Collection
├── _data/            ## Global data
│   ├── metadata.json
│   ├── nav.json
│   ├── social.yaml   ## YAML supported
│   └── config.yml    ## yml also supported
├── templates/
│   ├── layouts/      ## default.cax, home.cax, posts-list.cax
│   └── partials/     ## header.cax, footer.cax
├── public/           ## Static assets copied to site/
└── site/             ## Output generated

Frontmatter

Supports YAML nested objects and list of objects:

---
title: My Post
layout: default.cax
hero:
  title: Welcome
  subtitle: Fast SSG
features:
  - title: 0.4s Builds
    desc: Blazing fast
    icon: fast
  - title: Zero Deps
    desc: No Node.js needed
tags:
  - c
  - ssg
---

Data Files

Eleventy-style auto loading. Supports JSON and YAML.

_data/social.yaml:

github: https://github.com/mesinkasir
links:
  - title: Docs
    url: /docs/
  - title: Blog
    url: /posts/

Usage in template:

{{ social.github }}
{% for link in social.links %}
  {{ link.title }}
{% endfor %}

Supported: _data/.json, .yaml, *.yml

Templating Engine

Variables:

{{ title }}
{{ site.title }}
{{ social.github }}
{{ hero.title }}

If Else:

{% if title %}
  

{{ title }}

{% endif %} {% if not description %} No description {% else %} {{ description }} {% endif %} {% if pagination.prev_url %} Prev {% endif %}

For Loops:

{% for post in posts %}
  

{{ post.title }}

{% endfor %} {% for link in social.links %} {{ link.title }} - {{ link.url }} {% endfor %}

Includes:

{% include header.cax %}
{% include footer.cax %}

Collections and Pagination

Create controller file content/posts.md:

---
collection: posts
layout: posts-list.cax
title: Blog Posts
pagination: 6
---

This will scan content/posts/*.md and generate paginated list at /posts/, /posts/2/, etc.

Live Reload Development

cax start
  • Watches content/, templates/, _data/, public/
  • Auto rebuild on change
  • Auto inject cax_live.js - DEV ONLY
  • Auto open browser at http://localhost:8080

Production build is always clean:

cax build
cax serve

No live.js in production.

Deployment

Upload site/ folder to Netlify, Vercel, Cloudflare Pages, or any static hosting.

cax build

Features

  • Written in pure C
  • 0.4s builds for 100+ pages
  • Zero dependencies
  • Minified CSS auto
  • Sitemap, RSS, JSON Feed auto generated
  • YAML and JSON data support
  • Nested objects and list of objects

Support This Project

CAX is open source and free forever. If you find it useful, please consider supporting:

GitHub Sponsors:

https://github.com/sponsors/mesinkasir

PayPal:

https://www.paypal.com/cgi-bin/webscr?cmd=s-xclick&hostedbutton_id=JVZVXBC4N9DAN

Gumroad:

https://creativitaz.gumroad.com/coffee

Your support helps us maintain, improve, and add more features to CAX.

License

MIT - By Axcora - www.axcora.com