Inserting Partials with template and include
Why include composes with pipelines and template does not.
Inserting Partials with template and include is a free Helm Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Calling a Partial
A defined partial does nothing until you call it. Helm gives you two actions for this: template and include.
The template Action
The template action renders a named partial inline. You pass the partial name and a scope object for it to read.
{{ template "mychart.labels" . }}Why template Is Limited
The template action is a statement, not an expression. Its output goes straight to the document and cannot be piped to other functions.
Enter include
Helm adds the include function to fix that gap. It renders the same partials but returns the result as a string you can transform.
{{ include "mychart.labels" . }}include Composes With Pipelines
Because include returns a value, you can pipe it into functions like indent or nindent. This is why charts almost always prefer include.
{{ include "mychart.labels" . | indent 4 }}Indentation Is the Real Reason
Inserted YAML must land at the right indent. Only include can be piped to nindent, so it produces correctly nested output every time.
metadata:
labels:
{{- include "mychart.labels" . | nindent 4 }}The Scope Argument
The dot after the partial name is the scope you hand to it. Passing the root dot lets the partial read .Values and .Release.
{{ include "mychart.fullname" . }}A Helper That Builds a Name
Here a partial returns a name, and a Deployment uses include to drop it into metadata. One source of truth, many callers.
metadata:
name: {{ include "mychart.fullname" . }}template Has Its Place
You still see template in the wild, often for partials that emit a full block on their own line where no piping is needed.
{{ template "mychart.notes" . }}Rule of Thumb
If the output needs indenting or any post-processing, reach for include. Use the plain template action only when you truly do not.
Render to Confirm
Run helm template . and check the partial expanded with the indentation you expected. Misaligned YAML is the classic mistake here.
helm template my-release .Quick Check
You need to render a partial and indent it under a labels key. Which action works?
Recap: template vs include
Both call partials, but include returns a pipeable string while template only emits inline. Prefer include with nindent for clean YAML. ✨
Frequently asked questions
Is the “Inserting Partials with template and include” lesson free?
Yes — the full text of “Inserting Partials with template and include” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.
What will I learn in “Inserting Partials with template and include”?
Why include composes with pipelines and template does not. You practise Helm Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Helm Academy?
No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Inserting Partials with template and include” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Helm Academy lesson?
Yes. Every Helm Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Defining a Partial with define
- Inserting Partials with template and include
- The Standard Fullname and Labels Helpers
- Passing Scope into a Named Template