Skip to content

Templates & Partials

Gozzi uses Go's standard html/template package for rendering HTML, providing a powerful and flexible templating system.

Templates Guide

Getting Started

Template Data

Components

Examples

Quick Example

Basic post template:

html
<!DOCTYPE html>
<html lang="{{ .Site.Config.lang }}">
{{ template "partials/_head.html" . }}
<body>
    {{ template "partials/_header.html" . }}
    
    <main>
        <article>
            <h1>{{ .Page.Config.title }}</h1>
            <time>{{ date .Page.Config.date "January 2, 2006" }}</time>
            {{ .Page.Content }}
        </article>
    </main>
    
    {{ template "partials/_footer.html" . }}
</body>
</html>

Directory Structure

templates/
├── home.html            # Homepage
├── blog.html            # Blog list
├── post.html            # Blog post
├── partials/            # Shared snippets
│   ├── _head.html
│   ├── _header.html
│   └── _footer.html
└── macros/              # Reusable components
    ├── alert.html
    └── pagination.html

Start with: Template Structure to understand template organization.

Released under the MIT License.