GetPage not working on nested headless leaf bundles?

Hello to everyone,

I’m trying to understand how headless bundles work to create include functionality and I feel that I miss something…

To show my problem I’ve created following repository as a reference.

Structure of project looks like this:

├── archetypes
│   └──
├── config.yaml
├── content
│   ├──
│   ├── includes
│   │   ├──
│   │   └──
│   └── otherpage
│       ├── incl
│       │   ├──
│       │   └──
│       └──
├── layouts
│   ├── _default
│   │   ├── index.html
│   │   └── single.html
│   └── shortcodes
│       └── include.html

Run hugo serve and open localhost:1313/otherpage/ you will see that from otherpage/ only include has been rendered. from nested inlc has not.

/includes and /otherpage/incl are both leaf bundles and marked as headless: true. Why first is accessible and second is not?

I’ve added some warn messages to include shortcode for debug purpose. Message appear in console on first render only and when shortcode is saved. For some reason second shortcode in file don’t execute…

And life reload stopped to work for some reason (if you will add/remove shortcode you need manually refresh the browser).

Following Hugo build was used:

$ hugo version
Hugo Static Site Generator v0.72.0/extended darwin/amd64 BuildDate: unknown

Any help will be appreciated. Thanks!

Adding a comment to raise it in activity. Was hidden due to spam check.

There is no such thing as a “nested leaf bundle”. It’s a leaf node, so it has no descendants.

That said, with a recent Hugo version, you can use the _build keyword and make any page a “headless bundle”, even sections.

1 Like

Thanks for your answer!

By “nested leaf bundle” I meant that it is not on first level (like content/includes) in content directory.

Yes, approach with _build keyword seems to work.

Then I need to understand how headless: true works… If I read correctly in the docs:

A headless bundle is a bundle that is configured to not get published anywhere
But you can get it by .Site.GetPage .

It should behave the same way as manually configured _build. Am I correct or miss something?

By what does not work, I meant this:

│   └── otherpage
│       ├── incl
│       │   ├──
│       │   └──
│       └──

incl is a leaf, right?

I was happy with answer because it worked… But seems like it doesn’t :frowning:

It not works when I start hugo serve. It renders only include from /includes/ file.
While server is running, I delete otherpage/incl/ and recreate it. Now include from otherpage/incl/ is also on the screen.

Now I stop the server. Run hugo to build the website. Open public/otherpage/index.html. Only is included. (public dir was deleted before running the command)

Have I missed something in configuration? :thinking: :frowning:

otherpage is a leaf.

Got it. Because it has only. Thanks!

But behaviour described — is it something expected?

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