static

command
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 14 Imported by: 0

README

Static Generator Walkthrough

This example seeds a minimal in-memory site and runs the static generator to produce a multi-locale build. It demonstrates how themes, menus, and the template contract compose without relying on external storage or template engines.

What it does

  • Registers English and Spanish locales plus a reusable Demo Page content type.
  • Seeds five translated pages (/, /company, /services, /blog, /contact) and wires them into a primary navigation menu.
  • Registers a lightweight theme with Go templates, a go-theme manifest, and static assets (CSS + SVG logo).
  • Streams the generator output to ./dist/static-demo, including HTML, assets, and sitemap/robots files.

Run it

/Users/goliatone/.g/go/bin/go run ./examples/static

After completion you should see log output confirming the page/asset counts and the build duration:

static build complete: pages=4 assets=2 duration=45.321ms
output written to dist/static-demo

Output layout

dist/static-demo/
├── assets/
│   ├── logo.svg
│   └── theme.css
├── en/
│   ├── blog/index.html
│   ├── company/index.html
│   ├── contact/index.html
│   ├── index.html
│   └── services/index.html
├── es/
│   ├── blog/index.html
│   ├── contacto/index.html
│   ├── empresa/index.html
│   ├── index.html
│   └── servicios/index.html
├── index.html
├── robots.txt
└── sitemap.xml

Files under en/ and es/ mirror the locale-specific routes while the default locale is also promoted to the root for convenience.

Template contract highlights

The demo theme uses the generator.TemplateContext helpers showcased in:

  • templates/layout.tmpl for locale-aware navigation, go-theme asset resolution via .Theme.AssetURL, CSS variable injection, and build metadata.
  • templates/page.tmpl which simply delegates to the layout for clarity.

Check support.go for a reference Go template renderer and filesystem storage adapter—these illustrate how embedders can satisfy the generator interfaces without additional dependencies.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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