Greetings all, extremely new Hugo developer here and new to this forum, please feel free to offer feedback on both this question and how I’m asking it:
The organization where I work has a number of small multilingual sites using Hugo with the “portio” theme from StaticMania (here is their theme repo link and their web site) and in recent weeks, after the release of Hugo v0.112.0 which changes certain language-related variables, those sites have stopped building properly.
What happens, exactly, is that partials which would previously have shown up and displayed their content correctly based on language are not rendering content at all. The pages essentially have top navigation and footers, but no content is displayed in between by any “section” partials. Here are examples of two such partials from the simplest of the sites:
/layouts/partials/hero.html
{{ $data := index site.Data site.Language.Lang }}
{{ if $data.hero.enable }}
{{ with $data.hero }}
<section class="hero" id="home">
<div class="container">
<div class="row">
<div class="col-lg-10">
<div class="hero_content">
<div class="mb-5">
<h1>{{ .title }}</h1>
{{ .content | markdownify }}
</div>
</div>
</div>
<div class="col-lg-2">
<div class="hero_figure">
<img src="{{ .image | relURL }}" alt="{{ .imageDescription }}" />
</div>
</div>
</div>
</div>
</section>
{{ end }}
{{ end }}
/layouts/partials/ServiceSection.html
{{ $data := index site.Data site.Language.Lang }}
{{ if $data.serviceSection.enable }}
{{ with $data.serviceSection }}
<section class="section service" id="service">
<div class="container">
<div class="row">
{{ $Section := .service }}
{{ range $Section }}
<div class="service__slider_item col-lg-4">
<div class="service__slider_item-icon">
{{ if .image }}
<h2 class="icon">
<img src="{{ .image | relURL }} " alt="{{ .imageDescription }}">
</h2>
{{ end }}
</div>
<div class="mt-5">
<h3 class="">{{ .ctaTitle }}</h3>
<a class="btn btn-primary mb-3 mr-3 btn-zoom"
href="{{ .ctaTarget | safeURL }}"><i class="fa fa-2x {{ .ctaIcon }}"></i> {{ .ctaName }}</a>
{{ if .infoTarget }}
<a class="btn btn-secondary mb-3 mr-3 btn-zoom"
href="{{ .infoTarget | relURL }}"> {{ .infoName }}</a>
{{ end }}
</div>
</div>
{{ end }}
</div>
</div>
</section>
{{ end }}
{{ end }}
I should probably add that I didn’t develop this site, but I’ve inherited its care and need to figure out how to fix whatever’s happening. We serve these sites from GitLab Pages, and recently I noticed that they weren’t building correctly using “latest” Hugo there, while working fine locally using slightly older Hugo. I noticed it wasn’t a GitLab problem when I updated my local Hugo environment past v0.112.0 and the same thing started happening.
I can keep the sites working by changing their CI/CD configuration at GitLab to just keep using an older version instead of “latest” but that hardly seems optimal, plus I would like to figure out and fix whatever is wrong so it doesn’t come up regarding sites we build in the future.
Here is the output of “hugo env” on my local machine, where I can now reproduce the problem (but have not been able to fix it).
hugo v0.113.0+extended darwin/arm64 BuildDate=unknown
GOOS="darwin"
GOARCH="arm64"
GOVERSION="go1.20.4"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"
I believe the problem is being caused by the use of outdated variable naming like site.Language.Lang, but what’s confusing to me is that even when I use variables that still exist in current Hugo like site.LanguageCode or even hard code in “en” or “fr” or the like, something about the logic in these templates still fails. If I just dump out the contents of site.Data, I can see that it all exists, but for some reason the tests/iterating that used to output the page content are just not working now.
Thank you so much in advance to anyone who can point me in the right direction!