Skip to content

templ

An HTML templating language for Go with strong editor and IDE support.

Stars
10.6k
Forks
380
Licence
MIT
Language
Go
Last update
6 days ago
Type
Library

What it is

templ is a language for writing HTML user interfaces in Go. You write templates in a dedicated .templ format, and templ generates Go code from them that renders HTML. The README highlights its developer tooling, including IDE support through a language server.

  • Write reusable HTML components in Go with templ files
  • Render server-side HTML pages in a Go web application
  • Use the language server features in a supported editor while editing templates

Great for

  • Go developers building server-side rendered web pages
  • Teams using Go with htmx or similar HTML-first approaches
  • People who want typed HTML components in Go instead of string templates

Not ideal for

  • People who do not use Go, since templ is specifically for Go code
  • Projects that need a JavaScript-heavy front end framework as the main UI layer
  • Beginners with no Go experience, who would need to learn Go first
Step-by-step guide: how to use templInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Clone and build from source

    You'll need: Go · Git

    Clone the repository

    git clone https://github.com/a-h/templ

    Generate templ files using the local version

    go run ./cmd/templ generate -include-version=false
  2. 2

    Run it

    • Clone the repository and open it in a terminal.
    • Run the generate command to build templ from source.
    • Write a .templ file and run templ generate to produce Go code.
    • Run your Go program to render the HTML output.
  3. 3

    Get the most out of it

    • Use the language server features in a supported editor for completions and diagnostics
    • Run go test ./... after changes to check behavior
    • Run templ fmt to format templ files consistently
    • See the user documentation at templ.guide for full guidance

Downloads

Strengths

  • Built specifically for Go, so templates fit naturally with Go code
  • The README highlights editor and language server tooling
  • Released under the permissive MIT license

Trade-offs

  • Templates must be generated into Go code before they run, adding a build step
  • Only useful inside the Go ecosystem
  • The README given here is truncated, so details about editor setup and features are limited

How it compares

ProjectStarsTypeLevelUpdatedBest for
templ (this)10.6kLibraryintermediate6 days agoGo developers building server-side rendered web pages
react-loadable16.5kLibraryintermediate2.3 years agoReact developers whose main JavaScript bundle has grown large
coc.nvim25.1kAppintermediate10 days agoVim or Neovim users who want autocompletion and language features similar to VS Code
marko14.5kFrameworkintermediate6 days agoJavaScript developers who prefer HTML-style templates over JSX

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.