Javascript mysteriously stopped loading

I am using the Astatine theme. My website is hosted here.

On the initial commit to the repo, the Javascript from the theme was loaded in properly and worked fine. It is loaded in at the bottom of the partial head.html:

<!-- Common JS -->
{{ $commonJs := resources.Get "js/common.js" | resources.Minify }}
<script>{ { $commonJs.Content | safeJS } }</script>

loading in the file" themes\hugo-astatine-theme\assets\js\common.js

Something broke, I believe, at commit eb7b56e in the repo and all of the js stopped working. That includes the lower function in head.html which I had to comment out because it was suddenly not found. I didn’t realize the rest of the js (menu buttons etc.) had also broken until just now.

I’m not sure which change did it. It looks like I ran hugo on my local machine for the first time in a while on that commit, because all of the baseurls in public/ were updated there, but the base url in hugo.toml was actually updated a number of commits before that. Is that what is causing the problem, or one of the other changes I made there? I appreciate any help!

This change messes it up, you added spaces {<here>{ and }<here>}.

- <script>{{ $commonJs.Content | safeJS }}</script>
+ <script>{ { $commonJs.Content | safeJS } }</script>

I also recommend you remove the public directory from the repo. There is no need for it and it just makes the commit history etc. harder to read.

I also noticed that the theme to not fully support being used in a subdirectory. See the link in the head for “site.webmanifest” as an example.

Themes should always use Hugo funktions to build URLs, then Hugo will make sure links always work.

1 Like

And pretty cool having your project being “Exploring Titan’s Plains with RADAR Modeling” :slight_smile: .

Yes, that’ it! Thanks so much.

It seems like the default format-on-save from VScode makes that change. I did some googling, but there does not seem to be an easy way around that, without turning the feature off entirely for .html files. Do you have any suggestions?

And about the Titan project, thanks! Hopefully the actual project content will be filled in soon, and not just the description :slight_smile:

I format my html in vs code using prettier with go-templates plugin.

No broken {{ }} anymore

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