<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Resource methods on Hugo</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/</link><description>Recent content in Resource methods on Hugo</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://v0-122-0--gohugoio.netlify.app/methods/resource/index.xml" rel="self" type="application/rss+xml"/><item><title>Colors</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/colors/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/colors/</guid><description>New in v0.104.0 {{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .Colors }} → [#bebebd #514947 #768a9a #647789 #90725e #a48974] {{ end }} This method is fast, but if you also scale down your images, it would be good for performance to extract the colors from the scaled image.
Use this method with global, page, or remote resources.</description></item><item><title>Content</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/content/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/content/</guid><description>The Content method on a Resource object returns template.HTML when the resource type is page, otherwise it returns a string.
assets/quotations/kipling.txt He travels the fastest who travels alone. To get the content:
{{ with resources.Get &amp;#34;quotations/kipling.txt&amp;#34; }} {{ .Content }} → He travels the fastest who travels alone. {{ end }} To get the size in bytes:
{{ with resources.Get &amp;#34;quotations/kipling.txt&amp;#34; }} {{ .Content | len }} → 42 {{ end }} To create an inline image:</description></item><item><title>Crop</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/crop/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/crop/</guid><description>Crop an image to match the given dimensions without resizing. You must provide both width and height.
{{ with resources.Get &amp;#34;images/original.jpg&amp;#34; }} {{ with .Crop &amp;#34;200x200&amp;#34; }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} {{ end }} Use this method with global, page, or remote resources.
Process specification The process specification is a space-delimited, case-insensitive list of one or more of the following in any sequence:</description></item><item><title>Data</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/data/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/data/</guid><description>The Data method on a resource returned by the resources.GetRemote function returns information from the HTTP response.
{{ $url := &amp;#34;https://example.org/images/a.jpg&amp;#34; }} {{ with resources.GetRemote $url }} {{ with .Err }} {{ errorf &amp;#34;%s&amp;#34; . }} {{ else }} {{ with .Data }} {{ .ContentLength }} → 42764 {{ .ContentType }} → image/jpeg {{ .Status }} → 200 OK {{ .StatusCode }} → 200 {{ .TransferEncoding }} → [] {{ end }} {{ end }} {{ else }} {{ errorf &amp;#34;Unable to get remote resource %q&amp;#34; $url }} {{ end }} ContentLength (int) The content length in bytes.</description></item><item><title>Err</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/err/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/err/</guid><description>The Err method on a resource returned by the resources.GetRemote function returns an error message if the HTTP request fails, else nil. If you do not handle the error yourself, Hugo will fail the build.
In this example we send an HTTP request to a nonexistent domain:
{{ $url := &amp;#34;https://broken-example.org/images/a.jpg&amp;#34; }} {{ with resources.GetRemote $url }} {{ with .Err }} {{ errorf &amp;#34;%s&amp;#34; . }} {{ else }} &amp;lt;img src=&amp;#34;{{ .</description></item><item><title>Exif</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/exif/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/exif/</guid><description>Applicable to JPEG and TIFF images, the Exif method on an image Resource object returns an EXIF object containing image metadata.
Methods Date (time.Time) Returns the image creation date/time. Format with the time.Formatfunction. Lat (float64) Returns the GPS latitude in degrees. Long (float64) Returns the GPS longitude in degrees. Tags (exif.Tags) Returns a collection of the available EXIF tags for this image. You may include or exclude specific tags from this collection in the site configuration.</description></item><item><title>Fill</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/fill/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/fill/</guid><description>Crop and resize an image to match the given dimensions. You must provide both width and height.
{{ with resources.Get &amp;#34;images/original.jpg&amp;#34; }} {{ with .Fill &amp;#34;200x200&amp;#34; }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} {{ end }} Use this method with global, page, or remote resources.
Process specification The process specification is a space-delimited, case-insensitive list of one or more of the following in any sequence:</description></item><item><title>Filter</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/filter/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/filter/</guid><description>Apply one or more image filters to the given image.
To apply a single filter:
{{ with resources.Get &amp;#34;images/original.jpg&amp;#34; }} {{ with .Filter images.Grayscale }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} {{ end }} To apply two or more filters, executing from left to right:
{{ $filters := slice images.Grayscale (images.GaussianBlur 8) }} {{ with resources.Get &amp;#34;images/original.jpg&amp;#34; }} {{ with .Filter $filters }} &amp;lt;img src=&amp;#34;{{ .</description></item><item><title>Fit</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/fit/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/fit/</guid><description>Downscale an image to fit the given dimensions while maintaining aspect ratio. You must provide both width and height.
{{ with resources.Get &amp;#34;images/original.jpg&amp;#34; }} {{ with .Fit &amp;#34;200x200&amp;#34; }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} {{ end }} Use this method with global, page, or remote resources.
Process specification The process specification is a space-delimited, case-insensitive list of one or more of the following in any sequence:</description></item><item><title>Height</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/height/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/height/</guid><description>{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .Height }} → 400 {{ end }} Use the Width and Height methods together when rendering an img element:
{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34;&amp;gt; {{ end }} Use this method with global, page, or remote resources.</description></item><item><title>Key</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/key/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/key/</guid><description>By way of example, consider this site configuration:
hugo. yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; baseURL: https://example.org/docs/ baseURL = &amp;#39;https://example.org/docs/&amp;#39; { &amp;#34;baseURL&amp;#34;: &amp;#34;https://example.org/docs/&amp;#34; } And this template:
{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ with resources.Copy &amp;#34;foo/bar/b.jpg&amp;#34; . }} {{ .Key }} → foo/bar/b.jpg {{ .Name }} → images/a.jpg {{ .Title }} → images/a.jpg {{ .RelPermalink }} → /docs/foo/bar/b.jpg {{ end }} {{ end }} We used the resources.Copy function to change the publishing path.</description></item><item><title>MediaType</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/mediatype/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/mediatype/</guid><description>The MediaType method on a Resource object returns an object with additional methods.
Methods Type (string) The resource&amp;rsquo;s media type. {{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .MediaType.Type }} → image/jpeg {{ end }} MainType (string) The main type of the resource’s media type. {{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .MediaType.MainType }} → image {{ end }} SubType (string) The subtype of the resource’s media type. This may or may not correspond to the file suffix.</description></item><item><title>Name</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/name/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/name/</guid><description>The value returned by the Name method on a Resource object depends on the resource type.
Global resource With a global resource, the Name method returns the path to the resource, relative to the assets directory.
assets/ └── images/ └── a.jpg {{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .Name }} → images/a.jpg {{ end }} Page resource With a page resource, the Name method returns the path to the resource, relative to the page bundle.</description></item><item><title>Params</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/params/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/params/</guid><description>Use the Params method with page resources. It is not applicable to either global or remote resources.
With this content structure:
content/ ├── posts/ │ ├── cats/ │ │ ├── images/ │ │ │ └── a.jpg │ │ └── index.md │ └── _index.md └── _index.md And this front matter:
content/posts/cats.md yaml &amp;nbsp; toml &amp;nbsp; json &amp;nbsp; --- resources: - params: alt: Photograph of black cat temperament: vicious src: images/a.jpg title: Felix the cat title: Cats --- +++ title = &amp;#39;Cats&amp;#39; [[resources]] src = &amp;#39;images/a.</description></item><item><title>Permalink</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/permalink/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/permalink/</guid><description>The Permalink method on a Resource object writes the resource to the publish directory, typically public, and returns its permalink.
{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .Permalink }} → https://example.org/images/a.jpg {{ end }} Use this method with global, page, or remote resources.</description></item><item><title>Process</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/process/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/process/</guid><description>Process an image with the given specification. The specification can contain an optional action, one of crop, fill, fit, or resize. This means that you can use this method instead of Crop, Fill, Fit, or Resize.
{{ with resources.Get &amp;#34;images/original.jpg&amp;#34; }} {{ with .Process &amp;#34;crop 200x200&amp;#34; }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} {{ end }} You can also use this method to apply simple transformations such as rotation and conversion:</description></item><item><title>Publish</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/publish/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/publish/</guid><description>The Publish method on a Resource object writes the resource to the publish directory, typically public.
{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .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 }} Use this method with global, page, or remote resources.</description></item><item><title>RelPermalink</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/relpermalink/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/relpermalink/</guid><description>The Permalink method on a Resource object writes the resource to the publish directory, typically public, and returns its relative permalink.
{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .RelPermalink }} → /images/a.jpg {{ end }} Use this method with global, page, or remote resources.</description></item><item><title>Resize</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/resize/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/resize/</guid><description>Resize an image to the given width and/or height.
If you specify both width and height, the resulting image will be disproportionally scaled unless the original image has the same aspect ratio.
{{ with resources.Get &amp;#34;images/original.jpg&amp;#34; }} {{ with .Resize &amp;#34;300x&amp;#34; }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} {{ end }} Use this method with global, page, or remote resources.
Process specification The process specification is a space-delimited, case-insensitive list of one or more of the following in any sequence:</description></item><item><title>ResourceType</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/resourcetype/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/resourcetype/</guid><description>Common resource types include audio, image, text, and video.
{{ with resources.Get &amp;#34;image/a.jpg&amp;#34; }} {{ .ResourceType }} → image {{ .MediaType.MainType }} → image {{ end }} When working with content files, the resource type is page.
content/ ├── lessons/ │ ├── lesson-1/ │ │ ├── _objectives.md &amp;lt;-- resource type = page │ │ ├── _topics.md &amp;lt;-- resource type = page │ │ ├── _example.jpg &amp;lt;-- resource type = image │ │ └── index.</description></item><item><title>Title</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/title/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/title/</guid><description>The value returned by the Title method on a Resource object depends on the resource type.
Global resource With a global resource, the Title method returns the path to the resource, relative to the assets directory.
assets/ └── images/ └── a.jpg {{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .Title }} → images/a.jpg {{ end }} Page resource With a page resource, the Title method returns the path to the resource, relative to the page bundle.</description></item><item><title>Width</title><link>https://v0-122-0--gohugoio.netlify.app/methods/resource/width/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/methods/resource/width/</guid><description>{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ .Width }} → 600 {{ end }} Use the Width and Height methods together when rendering an img element:
{{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} &amp;lt;img src=&amp;#34;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34;&amp;gt; {{ end }} Use this method with global, page, or remote resources.</description></item></channel></rss>