Homework

Homework — type safety and an /about page

Make it yours.

  1. Feel the type safety. In home.templ, change @Layout("Home") to @Layout(42). Run templ generate — it won't even generate; you get a Go type error, cannot use 42 (int) as string, at that line. A template bug caught at build time. Fix it back.

  2. Trigger the stale-template gotcha on purpose. Edit the <h1> text in home.templ, reload without running templ generate — the old heading is still there. Now run templ generate, reload — your change appears. Feel the loop: edit → generate → reload.

  3. Turn your /about route (from lesson 1) into a real page. Write an About templ component that uses @Layout("About"), and change the About handler to render(w, r, http.StatusOK, web.About()). Now it's a styled page sharing the same header and footer — that's the point of a layout.

Where this is going. Your Home() renders, but it has nothing real to say — the "Skeleton status" card is hardcoded. Lesson 3 connects Postgres: a users table via a goose migration, queried with sqlc, and Home(userCount int64) will show a live count of registered users read from the database. And you'll meet the loveliest fact in the stack — sqlc reads its schema straight from the migrations, so the generated query code can never drift from the real table.