HUGO
Menu
GitHub 89737 stars Mastodon

Publish

Publishes the given resource.

Syntax

RESOURCE.Publish

Returns

nil

The Publish method on a Resource object writes the given resource to the publishDir.

This example uses resources.FromString to create a resource from a string, then publishes it:

layouts/baseof.html
{{ $content := printf "Contact: mailto:%s\n" site.Params.email }}
{{ with resources.FromString ".well-known/security.txt" $content }}
  {{ .Publish }}
{{ end }}

The Permalink and RelPermalink methods also publish a resource. Publish is a convenience method for publishing without a return value. For example, this:

{{ $resource.Publish }}

Instead of this:

{{ $noop := $resource.Permalink }}

To publish a resource within a pipeline, use the resources.Publish function instead.