tryck

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tryck

A single-binary static site generator for technical documentation, written in Go. Tryck is Swedish for "print".

Documentation: https://tryck.pinta.land/.

  • Plain Markdown plus ::: directives: admonitions, collapsible details and tabs that work without JavaScript.
  • Clear errors: every problem is reported as file:line:col: severity[code]: message, and the build reports all of them at once.
  • Correct docs output: link and anchor checking, .md links rewritten to page URLs, clean URLs, sitemap, feeds, search, redirects, and subpath deploys such as GitHub Pages project sites.
  • Fast: parallel parsing and rendering; about 80 ms for 1,000 pages on a laptop.
  • Themes: configure the built-in theme (accent, logo, light/dark, header links, footer, extra CSS) or package your own in a theme folder.
  • Extensible without a build step: custom ::: directives from templates and plugins in JavaScript, run by the stock binary. Go plugins for everything else.
  • Versioned docs: older releases under /v1/, /v2/ next to the current docs, with a version picker; tryck snapshot freezes a release.
  • Reader extras: copy buttons on code blocks, heading anchors, "Edit this page" links and "Last updated" dates from git.
  • Live reload: tryck dev rebuilds in memory, reloads the browser and shows build errors as an overlay.
  • No runtime dependencies: one static binary, no Node or Python in CI.

Quick start

tryck init my-docs
cd my-docs
tryck dev            # http://127.0.0.1:8080/
tryck build          # writes dist/

Download a binary for Linux, macOS or Windows from the releases page, or build from source with Go 1.26 or later:

go install github.com/Pinta365/tryck/cmd/tryck@latest

Commands

tryck build [--config tryck.config.yaml] [--output ./dist] [--drafts] [--base-url URL] [--workers N] [--strict] [--verbose]
tryck dev   [--config tryck.config.yaml] [--port 8080] [--host 127.0.0.1] [--open] [--verbose]
tryck init  [dir]
tryck version

Exit codes: 0 success, 1 build errors (or warnings with --strict), 2 usage or config errors. CLI flags override the config file, which overrides built-in defaults.

Content

content/
├── index.md                    → /
└── 01-guide/
    ├── _index.md               → /guide/          (section title and weight)
    ├── 01-install.md           → /guide/install/
    └── diagram.png             → /guide/diagram.png
  • Numeric prefixes order pages and are dropped from URLs. weight in front matter wins over them.
  • Link to other pages by their Markdown file, relative to the current file: [Install](01-install.md#download).
  • Pages with draft: true appear in tryck dev with a banner and are left out of tryck build unless you pass --drafts.

Directives:

:::note[Optional title]
Any **Markdown**.
:::

:::tabs{group=lang}
@tab Go
```go
x := 1
```
@tab TypeScript
```ts
const x = 1;
```
:::

Themes

The built-in theme is configured in tryck.config.yaml; most sites need nothing else:

theme:
  accent: "#0b7a5a"          # links, active nav, tabs
  logo: /img/logo.svg        # from static/
  colorScheme: auto          # auto (follows the system, with a toggle), light or dark
  nav:                       # header links
    - title: GitHub
      url: https://github.com/you/project
  footer: "© 2026 You. Built with [tryck](https://github.com/Pinta365/tryck)."
  css: [/css/custom.css]     # extra stylesheets, loaded last

Its styles live in /css/tryck.css and use CSS variables (--fg, --bg, --font, --accent, ...), so a stylesheet in theme.css can restyle the site without touching templates.

Theme folders package layouts, static files and defaults for reuse. Point theme.path at one:

themes/acme/
├── theme.yaml        # defaults for the theme section (accent, logo, footer, params, ...)
├── layouts/          # replaces built-in layouts with the same name
└── static/           # copied to the output root

Files are looked up in the site first, then the theme, then the built-in theme: layouts/partials/footer.html in your site beats the theme's, which beats tryck's. Settings in tryck.config.yaml win over theme.yaml key by key, except css: the site's stylesheets are added after the theme's. Custom values for a theme's templates go in theme.params and are available as .Theme.Params.

Layouts

Layouts are Go html/template files. To add analytics or other tags to every page, create layouts/partials/head-end.html or body-end.html; both are empty by default. See the built-in set in internal/render/layouts. Templates get .Site, .Page, .Content, .Nav, .TOC, .Prev, .Next and .Theme, and the functions relURL, absURL, dateFormat, markdownify, slugify, partial, default, dict and jsonify.

Custom directives

A template in layouts/directives/ adds a directive: layouts/directives/card.html renders :::card[Title]{href="guide/setup.md"} blocks, with the title, attributes and rendered body as template data; href and src are rewritten and checked like Markdown links. No code or build step. See Custom directives.

Script plugins

A JavaScript file in plugins/ is a plugin, run by the stock binary with nothing to install. Scripts have the same hooks as Go plugins: add data to pages, change the rendered HTML, write extra files and report diagnostics. See Script plugins.

// plugins/todo.js: warn about unfinished pages
function onPageParsed(page) {
  page.source.split("\n").forEach((text, i) => {
    if (text.includes("TODO")) page.report("warning", "unfinished section", i + 1);
  });
}

Plugins

Plugins are compiled in and hook into the build phases through the public API in pkg/plugin. The built-ins use the same API:

Plugin Config key Output
toc defaults.toc, defaults.tocDepth Table of contents per page
readingTime plugins.readingTime .Page.Data.readingTime in minutes
syntaxHighlighting plugins.syntaxHighlighting chroma highlighting with CSS classes; theme for light and darkTheme for dark mode, in /css/chroma.css
linkCheck plugins.linkCheck Broken link and anchor diagnostics
sitemap plugins.sitemap /sitemap.xml
search plugins.search A search box in the header, and /search-index.json
redirects A redirect page for each aliases entry
feed plugins.feed Atom or RSS feeds of dated pages, /feed.xml by default
mermaid plugins.mermaid ```mermaid blocks drawn as diagrams; the script loads from url (jsDelivr by default) only on pages that use it
Writing a Go plugin

A plugin is a Go type implementing plugin.Plugin plus any of the phase interfaces in pkg/plugin. Custom binaries compile plugins in and hand them to tryck.Main:

package main

import (
	"github.com/Pinta365/tryck/pkg/plugin"
	"github.com/Pinta365/tryck/pkg/tryck"
)

type Hello struct{ greeting string }

func (*Hello) Name() string { return "hello" }

// Declare the keys of the "plugins.hello" section, so a typo warns.
func (*Hello) ConfigKeys() []string { return []string{"greeting"} }

func (h *Hello) Init(cfg map[string]any, _ plugin.SiteInfo) error {
	h.greeting = "Hello"
	if v, ok := cfg["greeting"].(string); ok {
		h.greeting = v
	}
	return nil
}

func (h *Hello) OnPageParsed(p *plugin.Page) error {
	p.Data["greeting"] = h.greeting
	return nil
}

func main() { tryck.Main(&Hello{}) }

Build it with go build, for example go build ./examples/plugin-hello. See examples/plugin-hello for a complete, tested plugin, and Using plugins for setting up a site with a custom binary. ConfigKeys is optional; declaring it turns typos in the plugin's section into config.unknownKey warnings.

Deploying

tryck init includes .github/workflows/pages.yml, which downloads a release binary and deploys to GitHub Pages with the right --base-url. For Cloudflare Pages, use this build command with the output directory dist:

curl -sSL https://github.com/Pinta365/tryck/releases/latest/download/tryck_linux_amd64.tar.gz | tar xz tryck && ./tryck build

Development

go test -race ./...                      # all tests
TRYCK_UPDATE=1 go test ./internal/build  # accept new golden output in testdata/sites/*/expected
go test -run '^$' -bench . ./internal/build

License

MIT. See LICENSE.

Documentation

Overview

Package tryck embeds the starter site that tryck init copies. The command line is in pkg/tryck and the plugin API in pkg/plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Starter

func Starter() fs.FS

Starter returns the docs-starter example site that tryck init copies.

Types

This section is empty.

Directories

Path Synopsis
cmd
tryck command
Command tryck is a static site generator for technical documentation.
Command tryck is a static site generator for technical documentation.
examples
plugin-hello command
Command plugin-hello is a custom tryck binary with one extra plugin.
Command plugin-hello is a custom tryck binary with one extra plugin.
internal
build
Package build turns a site's inputs into an immutable Site snapshot.
Package build turns a site's inputs into an immutable Site snapshot.
config
Package config loads, defaults and validates tryck.config.yaml.
Package config loads, defaults and validates tryck.config.yaml.
content
Package content discovers source files and models pages: front matter, URL mapping and titles.
Package content discovers source files and models pages: front matter, URL mapping and titles.
devserver
Package devserver implements tryck dev: it builds the site into memory, serves it, rebuilds on file changes and tells browsers to reload over a WebSocket.
Package devserver implements tryck dev: it builds the site into memory, serves it, rebuilds on file changes and tells browsers to reload over a WebSocket.
diag
Package diag defines build diagnostics: a stable, file:line-addressed description of every problem found while loading or building a site.
Package diag defines build diagnostics: a stable, file:line-addressed description of every problem found while loading or building a site.
markdown
Package markdown configures goldmark: CommonMark plus GFM, unique heading IDs and tryck's ::: directives.
Package markdown configures goldmark: CommonMark plus GFM, unique heading IDs and tryck's ::: directives.
nav
Package nav builds the navigation tree that mirrors contentDir.
Package nav builds the navigation tree that mirrors contentDir.
output
Package output writes a built Site to disk.
Package output writes a built Site to disk.
plugins
Package plugins holds tryck's built-in plugins and the registry that enables, configures and orders them for a build.
Package plugins holds tryck's built-in plugins and the registry that enables, configures and orders them for a build.
render
Package render loads layout templates and executes them for pages.
Package render loads layout templates and executes them for pages.
scaffold
Package scaffold creates a new site from a template file tree.
Package scaffold creates a new site from a template file tree.
scripts
Package scripts runs JavaScript plugins: plugins/<name>.js files that define the same hooks as Go plugins as plain functions.
Package scripts runs JavaScript plugins: plugins/<name>.js files that define the same hooks as Go plugins as plain functions.
workpool
Package workpool runs indexed work on a bounded number of goroutines.
Package workpool runs indexed work on a bounded number of goroutines.
pkg
plugin
Package plugin is tryck's public plugin API.
Package plugin is tryck's public plugin API.
tryck
Package tryck is the public entry point of the tryck command line.
Package tryck is the public entry point of the tryck command line.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL