A while back the
page method was introduced, giving us access to the current page object. I thought that this is supported anywhere, in any layout, but when I run my website with a specific shortcode that is loading page resources via
page.Resources. inside of the shortcode this is not working the first time when I run the server - the page object contains the archive page for all subsequent shortcode calls (created via
content/archive/index.md. The first shortcode call works as expected. Every subsequent time it is called (all markdown files inside of a section have that shortcode) the return of
page.Resources is empty (the archives page has no resources). After changing any arbitrary part of the specific shortcode layout file and waiting for the server to reload, the page object is filled properly and the resources exist.
.Page.Resources. instead of
page.Resources in the shortcode fixes this behaviour.
So my question is: Do we expect
page to work inside a shortcode? It feels like the output/content of the function is, when working, different too (
.Page gives more elements than
I couldn’t find a documentation page for
page (4 characters seem not enough to filter through the index to show usable entries in the search), so I am going only from the release notes in the link above.
page is not expected to return something usable, it should show some warning or error. Else I am 50/50 on this being a bug in Hugo or my own layout files. That it brings up the “Archives” page feels like an “sort alphabetically” thing on the pages-index.
Edit: hugo v0.114.1-e9b716ad9869b79e7c374bbdae4daf5ee6406bd4+extended linux/amd64 BuildDate=2023-06-23T11:02:58Z VendorInfo=gohugoio