You can do that, but there’s no need to…
layouts/_default/home.html
{{ partial "foo.html" . }}
layouts/partials/foo.html
{{ partial "bar.html" . }}
{{ define "partials/bar.html" }}
{{ return "baz" }}
{{ end }}
Notes:
- Always include the
.htmlsuffix when calling or defining the partial - Partials defined inline, as shown above, are globally available. That means there can be name collisions with templates in the partials directory, and with other inline partials. So, you might want to do something like this instead:
layouts/partials/foo.html
{{ partial "inline/foo/bar.html". }}
{{ define "partials/inline/foo/bar.html" }}
{{ return "baz" }}
{{ end }}