Helm _helpers.tpl Calling defined templates in other template definitions
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
In Helm, _helpers.tpl is where you define reusable template snippets such as chart names, labels, and common metadata blocks. The key mechanism is simple: define a helper with define, then call it from another template with include or template, passing the context object that the helper needs.
Core Sections
Defining a helper in _helpers.tpl
Helpers are named templates. A common example is a helper that builds a chart-specific full name.
The string "mychart.fullname" is the helper name. Namespacing helpers with the chart name is important because Helm loads all templates into one namespace during rendering.
Calling a helper from another template
The most common way to call a helper is include.
The final . passes the current context into the helper. Without that context, the helper cannot read values such as .Release.Name, .Chart.Name, or .Values.
Calling one helper from another helper
You can also call a helper from inside another helper definition. This is a very common pattern for labels.
Then in a manifest:
This is the normal answer to "how do I call a defined template inside another definition?" You use include and pass the right context again.
include versus template
Both include and template render a named template, but include is more convenient because it returns a string that can be piped through functions such as indent, nindent, trim, or quote.
That is why most modern Helm charts prefer include for helper usage inside YAML. template still works, but it is less composable in pipelines.
Passing custom data with dict
Sometimes a helper needs more than the default dot context. In that case, build a small object with dict.
This is useful when the helper should receive only the data it needs instead of the entire release context.
Indentation matters in YAML
A frequent Helm issue is not the helper itself, but where the rendered text lands in the output. Helpers that render YAML fragments usually need nindent so the final manifest stays valid.
Without the right indentation, the template may render syntactically invalid YAML even though the helper logic itself is correct.
Common Pitfalls
- Defining helpers with generic names and colliding with templates from other charts or subcharts.
- Calling a helper without passing the expected context object, which makes
.Values,.Chart, or.Releaseunavailable. - Using
templatewhereincludeplusnindentwould make YAML composition easier. - Forgetting indentation and producing invalid rendered manifests even though the helper output looks correct by itself.
- Letting helpers become mini-programs full of business logic instead of keeping them focused on reusable formatting and naming.
Summary
- Put reusable Helm snippets in
_helpers.tplwithdefine. - Call helpers from manifests or other helpers with
include "name" .. - Pass the right context every time, or build a custom one with
dict. - Prefer
includewhen you need to pipe the result throughindentor other functions. - Keep helper names namespaced and their responsibility small so charts stay readable and composable.
Related reading
- helm chart error can't evaluate field Values in type interface
- Helm Chart pass variable to dependency
- Helm chart passing multiple environment values for single key
- Helm Chart will install manually, will not install via Terraform
- Helm how to define .Release.Name value
- Helm Incompatible versions between client and server
- Helm charts and Ingress resources
- Helm configmap error Error UPGRADE FAILED ConfigMap my-service.v130 is invalid data Too long must have at most 1048576 characters

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.