<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xml:base="https://bjorn.now/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Hugo on bjorn.now</title><link>https://bjorn.now/tags/hugo/</link><description>Recent content in Hugo on bjorn.now</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 08 Oct 2025 15:14:34 +0200</lastBuildDate><atom:link href="https://bjorn.now/tags/hugo/feed.xml" rel="self" type="application/rss+xml"/><item><title>Hugo's resources.Get only finds files in assets/, not static/</title><link>https://bjorn.now/til/2025-10-08-hugos-resources-get-only-finds-files-in-assets-not-static/?utm_medium=feed</link><pubDate>Wed, 08 Oct 2025 15:14:34 +0200</pubDate><guid>https://bjorn.now/til/2025-10-08-hugos-resources-get-only-finds-files-in-assets-not-static/</guid><description>Hugo’s resources.Get only finds files in assets/, not static/.
I kept my assets/resources in static/ and didn’t get why I always had to write /absolute/urls and use hope as a strategy, when I moved them into assets/ I could look up all my assets.</description><content:encoded><![CDATA[<p>Hugo&rsquo;s <code>resources.Get</code> only finds files in <code>assets/</code>, not <code>static/</code>.</p>
<p>I kept my assets/resources in <code>static/</code> and didn&rsquo;t get why I always had to write <code>/absolute/urls</code> and use hope as a strategy,
when I moved them into <code>assets/</code> I could look up all my assets.</p>
<p>The below would fail because it couldn&rsquo;t find the asset:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-plain" data-lang="plain"><span class="line"><span class="cl">{{ with resources.Get &#34;/author/bjorn.jpg&#34; }}
</span></span><span class="line"><span class="cl">  &lt;img src=&#34;{{ .RelPermalink }}&#34; alt=&#34;Björn Andersson&#34;&gt;
</span></span><span class="line"><span class="cl">{{ end }}</span></span></code></pre></div>
</div>
<p>Hugo has global assets accessed through <code>resources.Get</code> which <strong>only</strong> looks up in <code>assets/</code>.
Then page assets that you get through <code>.Page.Resources.Get</code> instead, which I haven&rsquo;t used yet.</p>
<p>If you want to use both, then do like the <a href="https://github.com/gohugoio/hugo/blob/4414ef73f3cd490caf93e0d50a6102db9ab28318/tpl/tplimpl/embedded/templates/_shortcodes/figure.html#L9C5-L11C16">figure shortcode</a> and do it in an or:</p>
<div class=" copy-enabled">
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-plain" data-lang="plain"><span class="line"><span class="cl">{{- with or (.Page.Resources.Get $u.Path) 
</span></span><span class="line"><span class="cl">            (resources.Get $u.Path) -}}
</span></span><span class="line"><span class="cl">{{- $src = .RelPermalink -}}
</span></span><span class="line"><span class="cl">{{- end -}}</span></span></code></pre></div>
</div>]]></content:encoded></item></channel></rss>