| 1 |
--- |
| 2 |
title: Publish |
| 3 |
description: Publishes the given resource. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: nil |
| 9 |
signatures: [RESOURCE.Publish] |
| 10 |
--- |
| 11 |
|
| 12 |
{{% include "/_common/methods/resource/global-page-remote-resources.md" %}} |
| 13 |
|
| 14 |
The `Publish` method on a `Resource` object writes the resource to the publish directory, typically `public`. |
| 15 |
|
| 16 |
```go-html-template |
| 17 |
{{ with resources.Get "images/a.jpg" }} |
| 18 |
{{ .Publish }} |
| 19 |
{{ end }} |
| 20 |
``` |
| 21 |
|
| 22 |
The `Permalink` and `RelPermalink` methods also publish a resource. `Publish` is a convenience method for publishing without a return value. For example, this: |
| 23 |
|
| 24 |
```go-html-template |
| 25 |
{{ $resource.Publish }} |
| 26 |
``` |
| 27 |
|
| 28 |
Instead of this: |
| 29 |
|
| 30 |
```go-html-template |
| 31 |
{{ $noop := $resource.Permalink }} |
| 32 |
``` |