My website makes use of jQuery. When I bundle jQuery with the help of Hugo’s native asset bundling mechanism and afterwards minify yet again with Hugo’s native minification along with my other JS assets, then my website can’t make use of jQuery since there happens some errors as can be seen from down below.
The above piece of code is live now and it works fine. However, if I remove the stand alone jQuery injection line from the above code block then it fails and jQuery is no longer functional.
As you mentioned, yes, jQuery is included twice but they don’t collide. What I meant to say at first is that on my initial try(when I wasn’t injecting jQuery as a stand alone like now) my above bundling/minification(same code as above just no stand alone jQuery injection) was yielding the above errors in the screenshots.
So clearly there is something wrong going on with Hugo’s bundling or minification.
I tried cloning your git repo locally, but get this when running hugo server:
$ hugo server
Total in 102 ms
Error: Error building site: "/Users/zwbetz/Development/Sites/cansurmeli.com/content/posts/9 - Tips for iPhone Repair.md:62:5": failed to extract shortcode: template for shortcode "img" not found
OK, I misread the error message. What jQuery distribution are you using? I understand there are several for different “module setups”.
Your error says that the global “$” variable isn’t defined – you can verify this in the Chrome console:
console.log($);
> ƒ (e,t){return new w.fn.init(e,t)}
console.log(jQuery);
> ƒ (e,t){return new w.fn.init(e,t)}
The above is on a test with jQuery. If you use one of the CDN versions (meant for inclusion in the header), they should have both of the above globals set, but I suspect you could also do something like this:
The commands you gave to clone/init/update the theme submodule didn’t work, since the URL was SSH not HTTPS. I changed it to HTTPS, but then it prompted me for my git credentials. So I just deleted the submodule then did a plain git clone of it.
Oddly, I’m not seeing the error on my end. Chrome DevTools Console is clean. For reference, here is screenshot output of those commands bep mentioned
Nevermind, I see the error now when commenting out this line as you mentioned