gitmyhub

templ

Go ★ 10k updated 1d ago

A language for writing HTML user interfaces in Go.

A Go tool for writing HTML page components directly in Go files with full type checking, so template errors are caught at compile time instead of crashing in production.

GoHTMLLSPsetup: moderatecomplexity 3/5

Templ is a templating language for Go that lets developers write HTML component definitions directly in Go files, with full type safety and editor support. Instead of writing HTML in separate string-based template files where typos only show up at runtime, templ lets you define HTML components in a syntax that the compiler can check, catching errors before the code runs.

The project ships a command-line tool that compiles .templ files into standard Go code. This generated Go code is what actually runs on your server, meaning the templates have no runtime dependency on a template engine at the point of serving requests. The CLI also includes a formatter to keep templ files consistently styled.

Developer tooling is a focus of the project. Templ provides a Language Server Protocol (LSP) implementation, which means editors like VS Code, Neovim, or any other LSP-compatible editor can offer autocomplete, error highlighting, and go-to-definition inside .templ files the same way they do for regular Go code. The project README includes a GIF showing this IDE integration in action.

Templ is commonly used with HTMX, a library that adds interactivity to HTML by making server-round-trips on user actions. The combination is a pattern for building web UIs with Go on the server without writing JavaScript. Documentation and guides live at the templ.guide website.

The README for this repository is primarily a list of developer build tasks for contributors working on templ itself (building, testing, formatting, releasing), rather than a user introduction. Full user documentation is at the external docs site.

Where it fits