# Go templates

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/2026.3/llms.txt).

> **TL;DR**
> Tutorial: [Build a blog with Go templates](https://blog.jetbrains.com/go/2022/11/08/build-a-blog-with-go-templates/)

Go has its own template engine that is split into two packages: `text/template` and `html/template`. These packages are similar in functionality, with the difference that `html/template` allows a user to generate HTML code that is safe against code injection, making it suitable for use on web pages and emails. GoLand provides coding assistance for configuration files used by [Helm](https://helm.sh/), a package manager, and [Kubernetes](https://kubernetes.io/), a container orchestration platform.

To specify mapping of a type between a Go template and an application, GoLand uses the `gotype` comment of the following structure: `{{- /*gotype: package/path.type_name*/ -}}`.

For Go templates, the commonly used file extensions are:

* `.gohtml`: specifically indicates a Go HTML template, useful if your editor or IDE provides specialized support for these templates. GoLand has association with this extension.

* `.tmpl`: a general extension for template files, suitable for Go templates.

* `.tpl`: another general extension for template files used in Go.

Procedure: Define mapping of a type between Go template and application

1. Add an HTML tag (for example, `<title></title>`).

2. Inside an HTML tag, type `{{.}}`.

3. Place the caret after the dot, press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Ctrl+.` (VSCode), `⌘ .` (VSCode (macOS)), and select Specify dot type.

4. In the `gotype` comment section, select the necessary type from the code completion popup `Ctrl+Space` (Windows), `⌃ Space` (macOS), `⌃ Space` (IntelliJ IDEA Classic (macOS)), `⌃ Space` (macOS System Shortcuts), `Ctrl+Space` (XWin), `Ctrl+Space` (GNOME), `Ctrl+Space` (KDE), `Alt+/` (Emacs), `Ctrl+Space` (Sublime Text), `⌃ Space` (Sublime Text (macOS)), `Ctrl+I` (VSCode), `⌘ I` (VSCode (macOS)).

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/go_integration_with_go_templates.mp4)

[Files on GitHub](https://github.com/apronichev/documentation-code-examples/tree/master/goTemplates).

> **Tip:**
> Alternatively, type `{{- /*gotype: */ -}}`, place the caret after `gotype:`, press `Ctrl+Space` (Windows), `⌃ Space` (macOS), `⌃ Space` (IntelliJ IDEA Classic (macOS)), `⌃ Space` (macOS System Shortcuts), `Ctrl+Space` (XWin), `Ctrl+Space` (GNOME), `Ctrl+Space` (KDE), `Alt+/` (Emacs), `Ctrl+Space` (Sublime Text), `⌃ Space` (Sublime Text (macOS)), `Ctrl+I` (VSCode), `⌘ I` (VSCode (macOS)), and select the necessary type.

