I am trying to get a pipeline for my js code to work, so I just wanted to get the most basic example going. I followed this simple example. This is baseof.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ $options := (dict "targetPath" "css/main.css") }}
{{ $stylemain := resources.Get "scss/main.scss" | toCSS $options }}
<link rel="stylesheet" href="{{ $stylemain.Permalink }}">
</head>
<body>
This is some test page.
{{ $built := resources.Get "js/main.js" | js.Build }}
<script src="{{ $built.RelPermalink }}"></script>
</body>
</html>
Yet on running hugo
I receive the error message
Error: Error building site: failed to render pages: render of "home" failed: "/home/fridde/examplesite/layouts/_default/baseof.html:384:42": execute of template failed: template: _default/list.html:13:42: executing "_default/list.html" at <js>: can't evaluate field Build in type string
What a totally unhelpful error message. Is “js” considered to be a string? Why?
I have tried to find documentation for resources.Get
and have tried to find where js.Build
is defined. But since I have no experience with Go, this has been a doomed project. It doesn’t seem to be a scope problem, as similar threads have suggested.
Also, the .scss conversion to .css in the <head>
works just fine without any problem.
Anyone who can point me to where things go wrong? How would you try to debug this?