I’ve tried creating the variable outside of the with statement but I still get the same error.
But when I comment out any reference to $stars and start the server, it starts up fine, and I then uncomment out the $stars code it works fine. Almost like the page is being rendered before it reads in the front matter.
Start building sites …
hugo v0.90.1-48907889+extended linux/amd64 BuildDate=2021-12-10T10:56:41Z VendorInfo=gohugoio
.File.Dir on zero object. Wrap it in if or with: {{ with .File }}{{ .Dir }}{{ end }}
Error: Error building site: failed to render pages: render of "page" failed: "/home/bab14/web_dev/hugo/mimijbakery.com/layouts/recipes/single.html:15:27": execute of template failed: template: recipes/single.html:15:27: executing "main" at <sub 5 .Params.stars>: error calling sub: can't apply the operator to the values
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.
ERROR 2021/12/15 11:01:58 Failed to render pages: render of "page" failed: "/home/bab14/web_dev/hugo/mimijbakery.com/layouts/recipes/single.html:44:51": execute of template failed: template: recipes/single.html:44:51: executing "main" at <index .Params.categories 0>: error calling index: index of untyped nil
Total in 53 ms