title: Unable to get partial to return images generated from title - Hugo
body: <p>Based on <a href="https://www.trysmudford.com/blog/random-to-a-point/" rel="nofollow noreferrer">this blogpost</a>, I am trying to generate a pseudo-random thumbnail for each new post. First, in my data folder I have a <code>bg.json</code> which contains information about the colours and SVGs like so:</p>
  <pre><code>{
    &quot;colours&quot;: [
      &quot;#dfe6e9&quot;,
      &quot;#00b894&quot;
    ],
    &quot;patterns&quot;: [
      &quot;data:image/svg+xml...&quot;
    ]
  }
  </code></pre>
  <p>Next, in the partials folder, I created a new partial called <code>thumbnail.html</code> which contains the following code:</p>
  <pre><code>{{ $hash := split (md5 .Title) &quot;&quot; }}
          {{ $totalColours := len .Site.Data.bg.colours }}
  
          {{ $primaryIndex := index $hash 1 }}
          {{ $basedPrimaryIndex := printf &quot;%x&quot; $primaryIndex }}
          {{ $modIndex := mod $basedPrimaryIndex $totalColours }}
          {{ $primary := index .Site.Data.bg.colours $modIndex }}
  
          
          {{ $secondaryIndex := index $hash 2 }}
          {{ $basedSecondaryIndex := printf &quot;%x&quot; $secondaryIndex }}
          {{ $modIndex := mod $basedSecondaryIndex $totalColours }}
          {{ $secondary := index .Site.Data.bg.colours $modIndex }}
  
  
          {{ $bgIndex := mod (printf &quot;%x&quot; (index $hash 0)) (len .Site.Data.bg.patterns) }}
          {{ $bg := replace (replace (replace (replace (index .Site.Data.bg.patterns $bgIndex) &quot;%3C&quot; &quot;&lt;&quot;) &quot;%3E&quot; &quot;&gt;&quot;) &quot;%23&quot; &quot;&quot; | safeHTML) &quot;data:image/svg+xml,&quot; &quot;&quot; }}
          {{ $colouredBg := replace $bg &quot;9C92AC&quot; $secondary }}
          &lt;style&gt;
              .post__header {
                  --color: {{ $primary }};
                  --bg: url(&quot;data:image/svg+xml;charset=utf-8;base64,{{ base64Encode $colouredBg }}&quot;);
              }
          &lt;/style&gt;
  </code></pre>
  <p>My theme generates portfolio cards in another partial called <code>portfolio.html</code>. I looked through the file and replaced the original <code>img src</code> with a path to my partial like so:</p>
  <pre><code> &lt;div class=&quot;box-masonry&quot;&gt;
                        {{ if and (isset .Params &quot;image&quot;) .Params.image }}
                          {{ if eq .Params.showonlyimage true }}
                          &lt;a href=&quot;{{ .Permalink }}&quot; title=&quot;&quot; class=&quot;box-masonry-image with-hover-overlay&quot;&gt;
                          {{ else }}
                          &lt;a href=&quot;{{ .Permalink }}&quot; title=&quot;&quot; class=&quot;box-masonry-image with-hover-overlay with-hover-icon&quot;&gt;
                          {{ end }}
                              &lt;img src=&quot;{{ partial &quot;thumbnail.html&quot; . }}&quot; alt=&quot;&quot; class=&quot;img-responsive&quot;&gt;
                          &lt;/a&gt;
       (...)
  </code></pre>
  <p>However, I am not seeing any images when I run my hugo server. I thought this would be the neatest way to approach things, but I think the post title (which is hashed to pick a random palette/pattern) is not being passed. How can I fix this?</p>
  <p><a href="https://i.stack.imgur.com/yFlsW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yFlsW.png" alt="enter image description here" /></a></p>
  <p>My repo is hosted here: <a href="https://github.com/thedivtagguy/archives" rel="nofollow noreferrer">https://github.com/thedivtagguy/archives</a></p>
  <p>The repo for the original blogpost's code is hosted here: <a href="https://github.com/trys/random-to-a-point" rel="nofollow noreferrer">https://github.com/trys/random-to-a-point</a></p>