Issue With Hugo Pipes

I am trying to use pipes to bundle my plugins and script modules.
This is my code so far.

{{ $jsBundle := slice }}
{{ $jsBundle = $jsBundle | append resources.Get  "plugins/google-map/map.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/jquery/jquery.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/lazy-load/lozad.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/magnific-popup/jquery.magnific-popup.min.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/shuffle/shuffle.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/slick/slick.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "js/script.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/boosting.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/coaching.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/placements.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/tourneyTitle.js" }}
{{ $jsBundle := $jsBundle | resources.Concat "js/bundle.js" | fingerprint "sha384" }}
<script src="{{ $jsBundle.Permalink | absURL }}"></script>

Whenever I run this code I get this error,

executing "partials/footer.html" at <resources>: wrong number of args for Get: want 1 got 0

So after trying to figure out how to fix this and trying to use filepath insteadof Get to use it I decided to go back to the way the tutorial i first watched did it. That link is here. Using Hugo Pipes to Bundle Scripts - YouTube You can skip to 17:00 to see where he gets the same exact error and then fixes it. The fix didnt work for me though.

{{ $jsBundle := slice }}
{{ range .Site.Params.plugins.js}}
{{ $jsFile := resources.Get .link | minify }}
{{ $jsBundle := $jsBundle | append $jsFile }}
{{ end }}
{{ $jsBundle := $jsBundle | resources.Concat "js/bundle.js" | fingerprint "sha384" }}
<script src="{{ $jsBundle.Permalink | absURL }}"></script>

When I try it this way instead the error message i get is

executing "partials/footer.html" at <resources.Concat>: error calling Concat: slice []interface {} not supported in concat

I can link the repo if neede. but rn it is not pushed fully. I would prefer to use the first way I listed that way i dont have to have multiple ranges for the plugins and the modules, and it lets me easily select what I want to use instead of auto everything.

Change this:

{{ $jsBundle = $jsBundle | append resources.Get "foo" }}

To this:

{{ $jsBundle = $jsBundle | append (resources.Get "foo") }}

Okay that fixed that. Now I am getting a GoLand warning saying that

{{ $jsBundle.Permalink | absURL }}

cannot resolve file

The .Permalink property is already an absolute URL. Why are you piping it through the absURL function?

I cannot troubleshoot this without access to the public repository for your project. See:

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.

1 Like

honestly I just did what the dude in the video did.

I cannot reproduce the “cannot resolve file” warning:

git clone --recurse-submodules
cd testsite1
Start building sites … 

                   | EN | FR  
  Pages            | 11 | 22  
  Paginator pages  |  0 |  0  
  Non-page files   |  0 |  0  
  Static files     | 51 | 51  
  Processed images |  0 |  0  
  Aliases          |  4 |  4  
  Sitemaps         |  2 |  1  
  Cleaned          |  0 |  0  

Total in 372 ms

There was one error while cloning your repository:

fatal: remote error: upload-pack: not our ref db1cb548bcea5bb4bcfec6f296df7fd509c310da
Fetched in submodule path 'themes/meghna-hugo', but it did not contain db1cb548bcea5bb4bcfec6f296df7fd509c310da. Direct fetching of that commit failed.

So what does this mean?

It means you should Google “fatal: remote error: upload-pack: not our ref”. Or maybe ask the dude in the video.

okay thank you for your help

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.