astwerk

4. More pages

A page is one entry in the tree — nothing else. pages/about.templ:

templ
package pages

templ About(title string, path string, prefix string) {
	@Layout(title, path, prefix) {
		<h1>About</h1>
		<p>This site is built with astwerk.</p>
	}
}

And one entry in the tree:

go
root := ssg.Node{
		Title: "My Site",
		Page:  ssg.Templ(pages.Home),
		Children: map[string]ssg.Node{
			"about": {Title: "About", Page: ssg.Templ(pages.About)},
		},
	}

That writes build/about/index.html. The Title is what the walker hands the page as its title argument — every page gets its title, path and locale from the tree it lives in.

Try it. Add a third page — say contact — as one more Children entry.

What you should see

build/contact/index.html appears and nothing else changes. A page really is one entry in the tree.

What does adding a page require?

What does one Children entry produce?