Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site builds with Hugo 122 but not 123 #12174

Closed
earthboundkid opened this issue Feb 28, 2024 · 15 comments
Closed

Site builds with Hugo 122 but not 123 #12174

earthboundkid opened this issue Feb 28, 2024 · 15 comments

Comments

@earthboundkid
Copy link
Contributor

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.123.6-92684f9a26838a46d1a81e3c250fef5207bcb735+extended darwin/arm64 BuildDate=2024-02-28T18:29:40Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes.

Output

$ hugo
Start building sites …
hugo v0.123.6-92684f9a26838a46d1a81e3c250fef5207bcb735+extended darwin/arm64 BuildDate=2024-02-28T18:29:40Z VendorInfo=brew

Total in 3903 ms
Error: error building site: render: failed to render pages: render of "page" failed: "/Users/cjohnson/src/spl/poor-richard/layouts/news/featured.html:33:7": execute of template failed: template: news/featured.html:33:7: executing "main" at <.Content>: error calling Content: "/Users/cjohnson/src/spl/poor-richard/content/news/2022-02-21-SPLCANNABIS21.md:296:1": failed to render shortcode "featured/series": failed to process shortcode: execute of template failed: template: shortcodes/featured/series.html:13:55: executing "shortcodes/featured/series.html" at <(site.Taxonomies.series.Get (urlize .)).Page>: error calling Page: WeightedPages is empty

Steps to reproduce

  • Clone github.com/spotlightpa/poor-richard
  • yarn install
  • Run hugo or hugo server

Workaround

Use Hugo 122

@earthboundkid
Copy link
Contributor Author

A little more info: You can get the site to build by commenting out this line in layouts/shortcodes/featured/series.html but the homepage still builds wrong with no featured items, which makes me think something in the page getter is broken

  {{ $series = (site.Taxonomies.series.Get (urlize . )).Page }}

@bep
Copy link
Member

bep commented Feb 29, 2024

The short story is that we have stopped "urlizing" the terms when we store them (there's a long story as to why).

So, you should be able to do:

{{ $series = (site.Taxonomies.series.Get (lower . )).Page }}

But ...

I would recommend that you rewrite the above to:

{{ $series := site.GetPage (printf "/series/%s" . ) }}

For several reasons, one being that GetPage is more lenient in what terms/paths it accepts.

@i0day
Copy link

i0day commented Feb 29, 2024

I am having the same problem when update to 123 or newer release. 122 is fine.

Start building sites …
hugo v0.123.6-92684f9a26838a46d1a81e3c250fef5207bcb735+extended linux/amd64 BuildDate=2024-02-28T18:29:40Z VendorInfo=gohugoio

Built in 280 ms
Error: error building site: render: failed to render pages: render of "section" failed: "/home/james/quickstart/layouts/_default/list.html:20:7": execute of template failed: template: _default/list.html:20:7: executing "main" – File is nil; wrap it in if or with: {{ with partial "article-meta/list.html" (dict "context" . "scope" "single")>: error calling partial: "/home/james/quickstart/layouts/partials/article-meta/list.html:17:32": execute of template failed: template: partials/article-meta/list.html:17:32: executing "partials/article-meta/list.html" at <partial "meta/views.html" .>: error calling partial: "/home/james/quickstart/layouts/partials/meta/views.html:7:28": execute of template failed: template: partials/meta/views.html:7:28: executing "partials/meta/views.html" at <.File }}{{ .Path }}{{ end }}

I am using blowfish theme. v2.58.0

Thank you

@jmooring
Copy link
Member

@i0day The behavior you noted is not related to this issue. See #12176, and create a topic on the forum (https://discourse.gohugo.io/) if you have any questions.

@earthboundkid
Copy link
Contributor Author

earthboundkid commented Feb 29, 2024

Using lower instead of urlize seems to work, but now I'm diagnosing why the homepage content selection was blank. It seems like we've been saying site.GetPage "content/news/story.md" since forever, but now it needs to be site.GetPage "news/story.md" to work (no content/ at the front). That seems like a bug to me.

@jmooring
Copy link
Member

@earthboundkid The fact that "content/something" worked before was either luck and/or undocumented behavior.

https://gohugo.io/methods/site/getpage/

When using the GetPage method on a Site object, specify a path relative to the content directory.

So this doesn't seem like a bug to me.

@earthboundkid
Copy link
Contributor Author

I am willing to believe this is Hyrum's Law. I've been including content/ for years, but I can go through and start stripping them out.

@earthboundkid
Copy link
Contributor Author

I am willing to believe the content thing was a bug on my part, but I still don't like the series thing because I don't see how I can write a site that will work with 122 and 123. site.GetPage (printf "/series/%s" . ) gets the page, not the Taxonomy, and using lower and urlize produce different results on the different versions.

@jmooring
Copy link
Member

v0.123.0 introduced a number of intentional breaking (not backward compatible) changes. This is one of them.

@earthboundkid
Copy link
Contributor Author

There's backward compatibility and there's forward compatibility. Breaking BC isn't ideal, but sometimes it's necessary to say you can't use feature A after version X. The solution for end users is you just have to drop using feature A and start using feature B instead.

v1 A only
v2 A & B <-- users should switch B here
v3 B only

Breaking taxonomy look up breaks forward compatibility because there's no way to write code that will work on both 122 and 123. You just have to do a hard cutover. I think breaking forward compatibility is basically always a mistake because it segments the community. If you're a theme author, you can't use feature A or B because you can't know if users have code from before or after the cut. You just have to drop everything and hope that in some amount of time you can introduce B after everyone has upgraded, but no one wants to upgrade because they will lose A. It's a mess.

@earthboundkid
Copy link
Contributor Author

earthboundkid commented Feb 29, 2024

I have found another issue. Hugo is now not using layouts/_default/author.terms.html for /authors/ anymore.

I can workaround this by setting layout = "author.terms" but this is a lot of breakage for one release. :-(

earthboundkid added a commit to spotlightpa/poor-richard that referenced this issue Feb 29, 2024
@jmooring
Copy link
Member

jmooring commented Mar 1, 2024

I have found another issue

Please open another issue.

@earthboundkid
Copy link
Contributor Author

This issue really wasn't ready to be closed in the first place. :-/ I found another problem which relates to the original problem. We have series with commas in their names. Now they are showing up twice in the list of series, once with the metadata from _index.md and once without it. The workaround of changing urlize to lower isn't going to work.

earthboundkid added a commit to spotlightpa/poor-richard that referenced this issue Mar 1, 2024
@earthboundkid
Copy link
Contributor Author

123 has somehow created a paginated 404 directory with 98 entries.

@jmooring
Copy link
Member

jmooring commented Mar 1, 2024

We are not going to track multiple problems in a single issue.
In my previous response I advised you to open another issue.
This issue is closed.

@jmooring jmooring reopened this Mar 1, 2024
@jmooring jmooring closed this as completed Mar 1, 2024
@gohugoio gohugoio locked and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants