Route Files

Learn how index.html and index.server.go files work together to power a route.

Route Files

Each route folder must contain an index.html file to define the markup for the page. Optionally, you can include an index.server.go file that exports a Go function used to fetch or compute dynamic data for the route.

When a request comes in:

  • If index.server.go exists, Barry runs the exported function.
  • The returned data is injected into the template defined in index.html.
  • The final rendered HTML is cached and served as a static file.
// routes/about/index.server.go
package main

type Data struct {
	Title string
}

func Handle() Data {
	return Data{ Title: "About Us" }
}

This approach gives you dynamic flexibility with static-level speed. See more usage patterns in Server Logic.