Gastro

A fresh take on Go web development

Cook up web pages with Go

Combine Go frontmatter with html/template markup in a single .gastro file. The compiler generates type-safe code with automatic file-based routing.

components/greeting.gastro
---
type Props struct {
	Name string
}

p := gastro.Props()
Name := p.Name
Greeting := "Hi, " + p.Name
---
<section>
	<h1>{{ .Greeting }}</h1>
	<p>Hello {{ .Name }}, nice to see you.</p>
</section>

Writing web-applications in Go

Frictions and how we've overcome them.

Go's package per directory is a pain-point for web-development. Pages are not a natural abstraction point like typical Go directories
Gastro generates a single package for all pages and components.
IDE support is lacking and templates are disconnected from the logic they present.
Gastro ships a language-server (LSP) for `.gastro` files that connects logic to markup seamlessly.

Journey of web development

A brief history of the web, and how we got here.

  1. 2026

    Hypermedia revolution

    Pain surfaces from now maintaining business-logic in 2+ places. "JavaScript fatigue" is common knowledge, and browser performance suffers. JS Platform authors solve this by adding server-side rendering

    It's time to go back to the server.

    Turbo, htmx, Datastar and more are bringing the business-logic back to the server. Not to repeat our old mistakes, but to take advantage of how far the web has come since the 1990s.

    Modern CSS, HTML5 and web-components didn't exist when we did our templates failed us. We're not hating on JavaScript. It's simply not as necessary as it once was.

  2. Early 2010s

    Single-Page-Applications

    Rich web-applications exist, but as user-experience expectations rose, the amount of jQuery snippets were starting to cause pain. Single-page applications and components (React, Vue, Angular, etc) were celebrated as our saviors.

  3. Mid 2000s

    Rise of JavaScript

    Google releases Gmail and Google Calendar with superior user-experience and developers all over the world looked at JS with new eyes. jQuery was born, but only used partially on top of existing server-rendered systems.

  4. Early 2000s

    Server Rendered HTML

    Systems came online and more complicated applications were needed. PHP, Perl, ASP.net were born. JavaScript was used for popups, period.

  5. Late 1990s

    Static web-pages

    The dawn of the world-wide-web. Geocities, Frontpage and Netscape. Pages were "dumb" and most interactivity was through cgi-bin forms.

Why Gastro?

Your programming language has strict types. Why doesn't that extend to templates and routing?

File-Based Routing

Pages in your pages/ directory automatically become routes. Dynamic parameters with [slug] syntax. No configuration needed — just create a file and it’s live.

Go Frontmatter

Write type-safe Go in the frontmatter, import libraries or services and make variables and functions available to your template.

HTML Body, using html/template

Uses the standard Go templating engine. Syntax validation and autocomplete for variables and functions.

Editors & Coding Agents

Full language server (LSP) with completions, diagnostics, and go-to-definition. For both the Go frontmatter and the HTML template body.

Extensions for VS Code, Zed and Nevim. More can be created as interest grows.

Single Binary Deploy

Templates and static assets are embedded at build time. Zero runtime dependencies. Ship one file anywhere.

Idiomatic Go

Standard Go syntax you already know. html/template, net/http, go:embed — no new language to learn, full type-safety throughout.

The project is still a Go project and you can build it as you see fit. We just take away the pain of managing page handlers and templates.

Hypermedia Ready

Use with Datastar or htmx for awesome user-experience and dynamic functionality that was once reserved for single-page-applications.

TODO: §3 eyebrow

TODO: §3 headline

TODO: §3 lede

TODO: pill 1 TODO: pill 2 TODO: pill 3
TODO: server file
TODO: server snippet
TODO: browser
TODO: rendered preview

Anatomy of a Gastro

Get a Gastro project running in under a minute.

Write a component

---
type Props struct {
    Title  string
    Author string
}

p := gastro.Props()
Title := p.Title
Author := p.Author
---
<article>
    <h2>{{ .Title }}</h2>
    <p>By {{ .Author }}</p>
</article>

Develop

# Start the dev server
gastro dev

# Watches for changes, rebuilds,
# and restarts automatically.
# Template changes are hot-reloaded.

Deploy

# Build a single binary
gastro build

# Templates and static assets are
# embedded. Ship one file anywhere.
./app