<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Resource functions on Hugo</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/</link><description>Recent content in Resource functions on Hugo</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://v0-122-0--gohugoio.netlify.app/functions/resources/index.xml" rel="self" type="application/rss+xml"/><item><title>resources.Babel</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/babel/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/babel/</guid><description>{{ with resources.Get &amp;#34;js/main.js&amp;#34; }} {{ if hugo.IsDevelopment }} {{ with . | babel }} &amp;lt;script src=&amp;#34;{{ .RelPermalink }}&amp;#34;&amp;gt;&amp;lt;/script&amp;gt; {{ end }} {{ else }} {{ $opts := dict &amp;#34;minified&amp;#34; true }} {{ with . | babel $opts | fingerprint }} &amp;lt;script src=&amp;#34;{{ .RelPermalink }}&amp;#34; integrity=&amp;#34;{{ .Data.Integrity }}&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt;&amp;lt;/script&amp;gt; {{ end }} {{ end }} {{ end }} Setup Step 1 Install Node.js Step 2 Install the required Node.js packages in the root of your project.</description></item><item><title>resources.ByType</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/bytype/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/bytype/</guid><description>The media type is typically one of image, text, audio, video, or application.
{{ range resources.ByType &amp;#34;image&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 }} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory.
For page resources, use the Resources.ByType method on the Page object.</description></item><item><title>resources.Concat</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/concat/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/concat/</guid><description>The resources.Concat function returns a concatenated slice of resources, caching the result using the target path as its cache key. Each resource must have the same media type.
Hugo publishes the resource to the target path when you call its Publish, Permalink, or RelPermalink methods.
{{ $plugins := resources.Get &amp;#34;js/plugins.js&amp;#34; }} {{ $global := resources.Get &amp;#34;js/global.js&amp;#34; }} {{ $js := slice $plugins $global | resources.Concat &amp;#34;js/bundle.js&amp;#34; }}</description></item><item><title>resources.Copy</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/copy/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/copy/</guid><description>New in v0.100.0 {{ with resources.Get &amp;#34;images/a.jpg&amp;#34; }} {{ with resources.Copy &amp;#34;img/new-image-name.jpg&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 }} The relative URL of the new published resource will be:
/img/new-image-name.jpg The target path must be different than the source path, as shown in the example above.
Use the resources.Copy function with global, page, and remote resources.</description></item><item><title>resources.ExecuteAsTemplate</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/executeastemplate/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/executeastemplate/</guid><description>The resources.ExecuteAsTemplate function returns a resource created from a Go template, parsed and executed with the given context, caching the result using the target path as its cache key.
Hugo publishes the resource to the target path when you call its Publish, Permalink, or RelPermalink methods.
Let&amp;rsquo;s say you have a CSS file that you wish to populate with values from your site configuration:
assets/css/template.css body { background-color: {{ site.Params.style.bg_color }}; color: {{ site.</description></item><item><title>resources.Fingerprint</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/fingerprint/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/fingerprint/</guid><description>{{ with resources.Get &amp;#34;js/main.js&amp;#34; }} {{ with . | fingerprint &amp;#34;sha256&amp;#34; }} &amp;lt;script src=&amp;#34;{{ .RelPermalink }}&amp;#34; integrity=&amp;#34;{{ .Data.Integrity }}&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt;&amp;lt;/script&amp;gt; {{ end }} {{ end }} Hugo renders this to something like:
&amp;lt;script src=&amp;#34;/js/main.62e...df1.js&amp;#34; integrity=&amp;#34;sha256-Yuh...rfE=&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt;&amp;lt;/script&amp;gt; Although most commonly used with CSS and JavaScript resources, you can use the resources.Fingerprint function with any resource type.
The hash algorithm may be one of md5, sha256 (default), sha384, or sha512.
After cryptographically hashing the resource content:</description></item><item><title>resources.FromString</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/fromstring/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/fromstring/</guid><description>The resources.FromString function returns a resource created from a string, caching the result using the target path as its cache key.
Hugo publishes the resource to the target path when you call its Publish, Permalink, or RelPermalink methods.
Let&amp;rsquo;s say you need to publish a file named &amp;ldquo;site.json&amp;rdquo; in the root of your public directory, containing the build date, the Hugo version used to build the site, and the date that the content was last modified.</description></item><item><title>resources.Get</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/get/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/get/</guid><description>{{ 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; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory.
For page resources, use the Resources.Get method on the Page object.</description></item><item><title>resources.GetMatch</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/getmatch/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/getmatch/</guid><description>{{ with resources.GetMatch &amp;#34;images/*.jpg&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 }} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory.
For page resources, use the Resources.GetMatch method on the Page object.
Hugo determines a match using a case-insensitive glob pattern.
Path Pattern Match images/foo/a.jpg images/foo/*.jpg true images/foo/a.</description></item><item><title>resources.GetRemote</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/getremote/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/getremote/</guid><description>{{ $url := &amp;#34;https://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;{{ .RelPermalink }}&amp;#34; width=&amp;#34;{{ .Width }}&amp;#34; height=&amp;#34;{{ .Height }}&amp;#34; alt=&amp;#34;&amp;#34;&amp;gt; {{ end }} {{ else }} {{ errorf &amp;#34;Unable to get remote resource %q&amp;#34; $url }} {{ end }} Options The resources.GetRemote function takes an optional map of options.
{{ $url := &amp;#34;https://example.org/api&amp;#34; }} {{ $opts := dict &amp;#34;headers&amp;#34; (dict &amp;#34;Authorization&amp;#34; &amp;#34;Bearer abcd&amp;#34;) }} {{ $resource := resources.</description></item><item><title>resources.Match</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/match/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/match/</guid><description>{{ range resources.Match &amp;#34;images/*.jpg&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 }} This function operates on global resources. A global resource is a file within the assets directory, or within any directory mounted to the assets directory.
For page resources, use the Resources.Match method on the Page object.
Hugo determines a match using a case-insensitive glob pattern.
Path Pattern Match images/foo/a.jpg images/foo/*.jpg true images/foo/a.</description></item><item><title>resources.Minify</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/minify/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/minify/</guid><description>{{ $css := resources.Get &amp;#34;css/main.css&amp;#34; }} {{ $style := $css | minify }} Any CSS, JS, JSON, HTML, SVG, or XML resource can be minified using resources.Minify which takes for argument the resource object.</description></item><item><title>resources.PostCSS</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/postcss/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/postcss/</guid><description>{{ with resources.Get &amp;#34;css/main.css&amp;#34; | postCSS }} &amp;lt;link rel=&amp;#34;stylesheet&amp;#34; href=&amp;#34;{{ .RelPermalink }}&amp;#34;&amp;gt; {{ end }} Setup Follow the steps below to transform CSS using any of the available PostCSS plugins.
Step 1 Install Node.js. Step 2 Install the required Node.js packages in the root of your project. For example, to add vendor prefixes to your CSS rules: npm i -D postcss postcss-cli autoprefixer Step 3 Create a PostCSS configuration file in the root of your project.</description></item><item><title>resources.PostProcess</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/postprocess/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/postprocess/</guid><description>{{ with resources.Get &amp;#34;css/main.css&amp;#34; }} {{ if hugo.IsDevelopment }} &amp;lt;link rel=&amp;#34;stylesheet&amp;#34; href=&amp;#34;{{ .RelPermalink }}&amp;#34;&amp;gt; {{ else }} {{ with . | postCSS | minify | fingerprint | resources.PostProcess }} &amp;lt;link rel=&amp;#34;stylesheet&amp;#34; href=&amp;#34;{{ .RelPermalink }}&amp;#34; integrity=&amp;#34;{{ .Data.Integrity }}&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt; {{ end }} {{ end }} {{ end }} Marking a resource with resources.PostProcess postpones transformations until the build has finished.
Call resources.PostProcess when one or more of the steps in the transformation chain depends on the result of the build.</description></item><item><title>resources.ToCSS</title><link>https://v0-122-0--gohugoio.netlify.app/functions/resources/tocss/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v0-122-0--gohugoio.netlify.app/functions/resources/tocss/</guid><description>{{ with resources.Get &amp;#34;sass/main.scss&amp;#34; }} {{ $opts := dict &amp;#34;transpiler&amp;#34; &amp;#34;libsass&amp;#34; &amp;#34;targetPath&amp;#34; &amp;#34;css/style.css&amp;#34; }} {{ with . | toCSS $opts }} {{ if hugo.IsDevelopment }} &amp;lt;link rel=&amp;#34;stylesheet&amp;#34; href=&amp;#34;{{ .RelPermalink }}&amp;#34;&amp;gt; {{ else }} {{ with . | minify | fingerprint }} &amp;lt;link rel=&amp;#34;stylesheet&amp;#34; href=&amp;#34;{{ .RelPermalink }}&amp;#34; integrity=&amp;#34;{{ .Data.Integrity }}&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt; {{ end }} {{ end }} {{ end }} {{ end }} Transpile Sass to CSS using the LibSass transpiler included in Hugo&amp;rsquo;s extended edition, or install Dart Sass to use the latest features of the Sass language.</description></item></channel></rss>