Error with .Site.BaseURL since Hugo 0.112

My site is based on beautiful theme Future imperfect slim. This theme is legacy now. It works fine up to Hugo 0.111.3.

Since Hugo 0.112 (I tested 0.112.1 with the theme’s example site. I didn’t test 0.112.0 on windows, since chocolatey does not know this) there is an error, see red encircled area in screenshot:

In the screenshot you can also see a part of the main.js. The original file is here. The BaseURL in the example site’s config is baseurl = "https://hugo-future-imperfect-slim.netlify.app/"

I have to admit this exceeds my coding/debugging skills. Release notes and also forum search couldn’t help me. Maybe you can give me a hint? Thanks!

From anywhere, in any template, you can get site values with:

site.Something

To get a site value from the top level context passed into a page, you can use either of these:

.Site.Something
.Page.Site.Something

Prior to v0.112.0 you could also do this:

.Site.Site.Something
.Page.Site.Site.Something

The constructs above are nonsensical, undocumented, and should never have worked. They were removed in v0.112.0.

Your theme uses the nonsensical constructs above. Look at these lines:

The theme author passes $.Site (which in this context is .Page.Site) into main.js here:
https://github.com/pacollins/hugo-future-imperfect-slim/blob/master/assets/js/main.js#L63-L64

And then they try to access the baseURL with .Site.BaseURL. Put the two together and you get…

.Page.Site.Site.BaseURL

To fix this, change lines 12 and 38 in layouts/partials/scripts.html, replacing $.Site with $.

To really fix this, use an actively maintained theme.

2 Likes

@jmooring Thank you for this quick and perfect answer. Issue is resolved :smiley:

1 Like

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