not_found_handler.mdin: /docs/cmd/demo-server/

You can see an example of the custom 404 page here.

import (



404 not found

Repurpose the nav tree and the two-column view to have something that looks ok.

var notFoundView veun.AsView = veun.MustMemo(&two_column.View{
	Title: "404 Not Found",
	Nav:   doc_tree.View(""),
	Main: el.Article{
			el.Text("404 Not Found"),
			el.A{el.Href("/"), el.Text("/ go home")},
			el.Text("The content you were looking for was not found."),

This view is memoized and rendered when the server is started, but continues to be represented as a view in the typesystem.

The handler returns both the view and a handler that only sets the response code to 404.

var notFoundHandler = request.HandlerFunc(func(r *http.Request) (veun.AsView, http.Handler, error) {
	return notFoundView, handler.WithStatus(http.StatusNotFound), nil