Template Overview
git-cliff uses Tera as its template engine to generate changelogs. Tera is a powerful template language based on Jinja2 and Django templates, allowing you to create highly customizable changelog formats.What is Tera Templating?
Tera is a template engine that processes text with embedded expressions and control structures. In git-cliff, templates define how your changelog looks by transforming Git commit data into formatted output. Key features:- Variable interpolation - Insert dynamic data like commit messages, authors, and dates
- Control flow - Use conditionals and loops to format output based on data
- Filters - Transform data with built-in and custom filters
- Macros - Create reusable template components
How Templates Work in git-cliff
git-cliff processes your Git history and provides a context (commit data, release information, etc.) to your templates. The templates transform this context into your final changelog. The basic flow:- Git data extraction - git-cliff parses commits, tags, and repository metadata
- Context building - Data is organized into a structured format (releases, commits, groups)
- Template rendering - Tera processes your templates with the context
- Changelog output - Final formatted changelog is generated
Template Sections
A git-cliff configuration defines three main template sections:Header
Rendered once at the beginning of the changelog. Perfect for titles, descriptions, and introduction text.Body
Rendered for each release in your changelog. This is where you iterate over commits, groups, and format individual entries.Footer
Rendered once at the end of the changelog. Useful for comparison links, metadata, or signatures.Template Configuration
Templates are defined in yourcliff.toml configuration file: