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 Structure - Directory layout and file organization
- Template Mapping - How content maps to templates
- Development Server - Live reload and hot reloading
Template Data
- Template Variables - Available data: Site, Section, Page
- Template Functions - Built-in functions for templates
- Priority & Inheritance - Configuration cascading
Components
- Partials - Reusable template snippets
- Macros - Advanced reusable components
- Advanced Patterns - Complex template patterns
Examples
- Complete Examples - Full template implementations
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.htmlStart with: Template Structure to understand template organization.