Hugo theme and module stopped working locally

Recently Hugo stopped working locally on a specific machine and I’m not sure why. After a good 4 hours of looking into this, I need some fresh pairs of eyes.

TLDR: The theme and a module of a previously working website with no code changes stopped working properly when run locally on a specific machine. Runs fine other places.

Machine

  • OS: macOS Monterey (12.2.1)
  • Go: go version go1.17.8 darwin/arm64 (previously was on 1.15 but upgraded while troubleshooting)
  • Hugo: hugo v0.96.0+extended darwin/arm64 BuildDate=unknown (previously was on hugo v0.94.2+extended darwin/arm64 BuildDate=unknown but upgraded while troubleshooting)

Full Background/Context

Without changing code that was working yesterday, I started getting this error when starting the server on my website: failed to extract shortcode: template for shortcode "block" not found

I understand this is a common error and some of the possible reasons this could be happening, but bear with me. The block shortcode is in the theme I’m using (Compose), and has not been changed in 2 years.

After troubleshooting, I found that changing my config.toml file from theme = ["github.com/onweru/compose"] to theme = "compose" got rid of this issue. However, another error started appearing: executing "index.html" at <partial "twemoji" .>: error calling partial: partial "twemoji" not found

This is from a module I’m using (hugo-mod-twemoji), which has not changed in almost a year. I had followed their documentation and added {{ partial "twemoji" . }} to the baseof.html file at the end of the <body> tag.

I found if I remove this line allows the website to run locally. This code/website worked previously, though, locally and remote. And I should be able to point to the same theme on GitHub.

I made a small change on another file and deployed to GitHub Pages to check the original code there. No errors occurred and the module is working as intended. So must be a local issue.

I re-cloned my own repository and saw the same issues. Tried nuking the theme and module, adding them back, and got the same thing.

I followed the theme’s getting started docs on my main laptop and another. On the second laptop I was able to download and run the theme’s example site just fine. On my main, it failed with the first error I encountered with the block shortcode.

In summary, this seems to be limited to my machine but not website-specific. It could in theory be theme-specific, but the module seems to be having problems independent of the theme.

Happy to provide more information as necessary. I’m pretty new to Hugo, so perhaps I’m missing something obvious. Thanks for reading this far!

Relevant Files

# confif.toml

...
theme = ["github.com/onweru/compose"]
...
[module]
[[module.imports]]
  path = "github.com/jakejarvis/hugo-mod-twemoji"

# go.mod

module github.com/<me>/<my_website>

go 1.15
# also upgraded and tried 1.17

require (
	github.com/jakejarvis/hugo-mod-twemoji v0.3.0 // indirect
	github.com/onweru/compose v0.0.0-20220404121451-13b85c7c54e5 // indirect
)
# go.sum

github.com/jakejarvis/hugo-mod-twemoji v0.3.0 h1:jfd+zYe2EyQhc40FWNqK1x+/YbCefw6ZuMpUcDlSbcc=
github.com/jakejarvis/hugo-mod-twemoji v0.3.0/go.mod h1:3A+EjJ50vQEkmnEfhEY3RqPXozuWudsGwHx2UAUn9tA=
github.com/onweru/compose v0.0.0-20220404121451-13b85c7c54e5 h1:EAIQxc03d8/w/7f3Wg+Qz65P/bbIYQ6zOCpEUYVInVY=
github.com/onweru/compose v0.0.0-20220404121451-13b85c7c54e5/go.mod h1:tf1kQIBUcwJ/3mRFU5eiMrMvsDScVTK2IEFsZE3hZOc=
github.com/twitter/twemoji v13.1.0+incompatible/go.mod h1:06L6PdKuWDx/Yh6s4B7yGkAeBmWZzbFZgfNnWlJPPYM=
# layouts/_default/baseof.html

...
  {{ partial "twemoji" . }}
</body>
</html>

What I suspect is the culprit here is the mix of theme and module imports. I guess you could argue that it should work, but in my head you should use one or the other (I kept the theme option mostly for backwards compability).

Try to move everything down to module:

[module]
[[module.imports]]
path = "github.com/onweru/compose"
[[module.imports]]
path = "github.com/jakejarvis/hugo-mod-twemoji"
1 Like

One other tip would be to clear out your mod cache:

hugo mod clean

or

hugo mod clean --all

1 Like

@bep Thanks for your input.

Changing to all module import gave me the same error, but keeping that change and clearing the mod cache made the website run fine again. So seems pretty likely a caching issue.

1 Like

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