I’ve upgraded Hugo and suddenly some parts of the website stopped rendering.
Like this one:
{{ $list := (where .Pages "Type" "td-feature-list") }}
{{ $len := (len $list) }}
{{ range $i, $p := $list }}
Content for these pages is structured as follows:
/content
|-- container-page
|-- td-feature
|-- td-intro.de.md
with the frontmatter as follows:
---
title: "Titel"
date: 2017-11-24T14:23:52+01:00
draft: false
headless: true
weight: 1
type: td-feature-list
featured_image: "td-feature-main.png"
color: green
---
Wenn man alle....
It was rendering with 0.111.3 but now with 0.126.2 half of the contents of the website is missing.
Would greatly appreciate any ideas. Thanks!
What does this mean? Are the pages missing on the list page? Are the pages not rendered to disk? Both?
This would be easier to troubleshoot if you were to share your project.
Unfortunately there is no public repository I could share with you.
This is not even a page, which is not being rendered, but parts of the main pages. The code above is a partial which is being included in a single.html
of a container page:
{{ define "navigation" }}
{{ partial "navigation" . }}
{{ end }}
{{ define "main" }}
{{ partial "manager-app/hero" . }}
{{ partial "manager-app/intro" . }}
{{ partial "manager-app/absences" . }}
{{ partial "manager-app/tasks" . }} <-- this partial is the code above
{{ partial "analytics/hero" . }}
{{ partial "analytics/intro" . }}
{{ partial "analytics/feature-list" . }}
{{ partial "team-app/testimonials" . }}
{{ partial "reviews" . }}
{{ partial "home/specials" . }}
{{ end }}
I can give you more details, if you tell me where I have to look.
See Requesting Help .
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.
Trying to re-create your setup with limited information is not terribly efficient.
Here is the repo you can look at
https://bitbucket.org/bureaug/hugo_test/src/master/
Specifically
themes/test-theme/layouts/partials/home/solution.html
themes/test-theme/layouts/partials/container/absences.html
themes/test-theme/layouts/partials/container/tasks.html
themes/test-theme/layouts/partials/container/feature-list.html
are not being rendered. I might have jumped couple of updates and am missing a breaking change, maybe? I really appreciate your time and effort. Thanks a lot in advance.
1 Like
The behavior changed in v0.123.6.
The headless
(boolean) setting in front matter has been functionally superseded by the build
options.
Setting headless: true
is equivalent to:
build:
render: never
list: never
But what you probably want, in this case, is:
build:
render: never
list: always
And since the default for build.list
is always
, you can do this:
build:
render: never
See https://gohugo.io/content-management/build-options/ .
The above will render the content you want on the home page, but if this were my site I would refactor the headless structure per this example:
https://gohugo.io/content-management/build-options/#example----headless-section
Then in templates such as “themes/test-theme/layouts/partials/home/solution.html” you can do:
{{ $list := (site.GetPage "/some/headless/section").Pages }}
The advantages of this approach:
Improved organization
No need to set “type” in front matter
You can cascade the build options down from the section page (_index.md) instead of setting them on every page
You can change the build options to…
build:
render: never
list: local
…which prevents them leaking into page collections such as site.RegularPages
.
1 Like
Joe, thank you for your time. I’ve pushed to the repo with some changes
build options, i.e. content/container/abs-feature/abs-intro.de.md
removed headless from frontmatter
added feature with tags, content/features/_feature1.de.md
Alas, it didn’t work as expected. Am I messing it up somewhere else?
Go 1.22.3
Hugo 0.126.1
macOS Monterey 12.7.2
Try this:
git clone --recurse-submodules https://github.com/jmooring/hugo_test
cd hugo_test
hugo server
This is the example you should use:
https://gohugo.io/content-management/build-options/#example----headless-section
We make the entire “home” section headless. Do not include “build” or “headless” settings in front matter.
1 Like
So do I understand this correctly:
I have to include _index.lang.md
to be able to call (.Site.GetPage(path/to/folder)).Pages
I have to remove headless from front matter
?
Also, the question with taxonomies is still unclear. Tags are set in front matter, but the range .Site.Taxonomies.tags.some_tag
is empty.
Yes. Otherwise there’s not a page to get.
Yes. See example site.
I’ll have a look at that.
1 Like
There were still three pages with headless: true
in front matter.
1 Like
Thank you, Joe! Really appreciate your help.
You’re welcome.
Let me know when I can remove the test repo (https://github.com/jmooring/hugo_test ).
system
Closed
May 22, 2024, 9:55pm
16
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.