Template Engines

20 projects

Go ships two template engines in the standard library: text/template and html/template. The HTML version applies context-aware escaping, so values written into HTML, attributes, JavaScript and URLs are escaped correctly, which makes it the safe default for server-rendered pages. The libraries here offer different syntax, compile-time type checking, or speed for large output.

templ is the most active project: you write .templ files that compile to Go functions, so components are type-checked and editors get language server support. quicktemplate also compiles templates to Go code. pongo2 follows Django template syntax, CloudyKit's jet and Razor provide other familiar syntaxes, and liquid implements Shopify's Liquid for user-editable templates. fasttemplate does simple placeholder substitution with no logic. sprout is a library of extra functions for text/template and html/template. A few entries such as maroto and bagme produce PDFs from layouts rather than HTML.

Start with html/template when templates are simple and you want no dependencies. Choose templ if you build many HTML components and want refactoring and type errors caught at build time, which pairs well with htmx-style apps. Choose liquid or pongo2 when non-Go developers or end users edit templates, since their syntax is familiar and can be sandboxed more easily than Go code.

templby a-h

A HTML templating language that has great developer tooling.

github.com/a-h/templGo 1.26+ 14 dependenciesv0.3.1100updated 3d ago

10.6k

quicktemplateby valyala

Fast, powerful, yet easy to use template engine. Converts templates into Go code and then compiles it.

github.com/valyala/quicktemplateGo 1.17+ 2 dependenciesupdated 13d ago

3.3k

pongo2by flosch

Django-like template-engine for Go.

github.com/flosch/pongo2/v7Go 1.25+ 1 dependencyv6.1.0updated 6mo ago

3.1k

marotoby johnfercher

A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.

github.com/johnfercher/maroto/v2Go 1.26+ 7 dependenciesv2.4.4updated 11d ago

2.8k

jetby CloudyKit

Jet template engine.

github.com/CloudyKit/jet/v6Go 1.16+ 1 dependencyv6.3.3updated 1mo ago

1.4k

fasttemplateby valyala

Simple and fast template engine. Substitutes template placeholders up to 10x faster than text/template.

github.com/valyala/fasttemplateGo 1.12+ 1 dependencyupdated 3y ago

916

Razorby sipin

Razor view engine for Golang.

github.com/sipin/gorazorGo 1.12+ No dependencies v1.2.2updated 1mo ago

885

egoby benbjohnson

Lightweight templating language that lets you write templates in Go. Templates are translated into Go and compiled.

github.com/benbjohnson/egoGo 1.13+ No dependencies v0.4.3updated 3y ago

588

goviewby foolin

Goview is a lightweight, minimalist and idiomatic template library based on golang html/template for building Go web application.

github.com/foolin/goviewGo 1.14+ 5 dependenciesv0.3.0updated 1y ago

463

liquidby osteele

Go implementation of Shopify Liquid templates.

github.com/osteele/liquidGo 1.25+ 4 dependenciesv1.9.2updated 2mo ago

360

sproutby go-sprout

Useful template functions for Go templates.

github.com/go-sprout/sproutGo 1.26+ 9 dependenciesv1.1.2updated today

233

Soyby robfig

Closure templates (aka Soy templates) for Go, following the official spec.

github.com/robfig/soyGo 1.12+ 5 dependenciesupdated 2y ago

176

bagmeby boxesandglue

HTML/CSS to PDF rendering with TeX-quality typesetting in pure Go.

github.com/boxesandglue/bagmeGo 1.25+ 2 dependenciesupdated 13d ago

115

goxby doors-dev

HTML templates as first-class Go expressions, with seamless editor support.

github.com/doors-dev/goxGo 1.25+ 8 dependenciesv0.3.3updated 20d ago

66

gotby goradd

A Go code generator inspired by Hero and Fasttemplate. Has include files, custom tag definitions, injected Go code, language translation, and more.

github.com/goradd/gotGo 1.20+ 2 dependencies1.5.0updated 9mo ago

39

tbdby lucasepe

A really simple way to create text templates with placeholders - exposes extra builtin Git repo metadata.

github.com/lucasepe/tbdGo 1.16+ 7 dependenciesv0.2.0updated 5y ago

26

liquidgoby Notifuse

Full Go implementation of Shopify's Liquid template engine.

github.com/Notifuse/liquidgoGo 1.25+ 1 dependencyv5.11.0updated 9mo ago

17

templatorby alesr

A type-safe HTML template rendering engine for Go.

github.com/alesr/templatorGo 1.26+ 2 dependenciesv1.2.0updated 1mo ago

13

gomponents

HTML 5 components in pure Go, that look something like this: func(name string) g.Node { return Div(Class("headline"), g.Textf("Hi %v!", name)) }.

gomponents.com

htmgo

Build simple and scalable systems with go + htmx

htmgo.dev

Esc

Type to search every entry. ↑↓ to move, Enter to open.