Advanced Features
See what SiteGen can do with data and logic.
Data Sorting & Limiting
Here we load `data/links.json`, sort it by name descending, and limit to 3 items.
range sort "name" "desc" (limit 3 (data "links.json"))- Home - /
- Features - /features
- Blog - /blog
Page Variables & Frontmatter
Variables defined in the YAML frontmatter of a page are accessible directly at the root context. For example, the
title of this page, accessed via {{.title}}, is Features.
Other built-in variables include:
{{.Today}}: 2026-03-29{{.Year}}: 2026{{.BasePath}}: /sitegen/{{.Dev}}: false
File Sources & Metadata
Dynamically listing files from `src/blog` using `sources` and accessing their individual frontmatter using
.Meta.<key> instead of root variables.
range sort "Meta.date" "desc" (sources "RelPath" "blog/*.html")- Pure CSS Design - 2026-01-03
- Incremental Builds - 2026-01-02
- Welcome to SiteGen - 2026-01-01
Pagination
You can easily paginate lists using the paginate function. This populates `.Page` and `.Pages`
automatically.
File Handlers
Check `src/css/styles.css` frontmatter to see how we handle file-specific build commands.
/* --- serve: echo "Serving CSS..." build: echo "Building CSS..." --- */