Page Bundles, links to subpages

Hi All,

I’m trying to get my head around the concept of “Page Bundles” when it comes to “Content Management”.
Let’s say I have a file structure like this:
$ tree 2020-11-10-new-blog-post/
2020-11-10-new-blog-post/
├── img
│ ├── part-1-img01.png
│ ├── part-1-img02.png
│ ├── part-2-img01.png
│ ├── part-2-img02.png
│ ├── part-3-img01.png
│ └── part-3-img02.png
├── index.md
├── part-1.md
├── part-2.md
└── part-3.md

The index will have a brief introduction of the blog post and a TOC that link to the other pages.
The “part-X” pages, will have links to eachother and to the index.
Reading [Page Bundles] from the docs it looks that this can be done in the concept of “Leaf Bundles”, as the example suggests:
content/
├── about
│ ├── index.md
├── posts
│ ├── my-post
│ │ ├── content1.md
│ │ ├── content2.md
│ │ ├── image1.jpg
│ │ ├── image2.png
│ │ └── index.md

However, I couldn’t manage to get the links to the “non index” pages working. from the index.md page I’ve tried:

[Part 1](part-1)
[Part 1](part-1.md)
[Part 1](/part-1)
[Part 1](/part-1.md)
[Part 1](../part-1)
[Part 1](../part-1.md)
[Part 1](2020-11-10-new-blog-post/part-1)
[Part 1](2020-11-10-new-blog-post/part-1.md)
[Part 1](2020/11/new-blog-post/part-1)      <==== This is what it should look like in my opinion
[Part 1](2020/11/part-1)
...

and many others combination, but always get 404 error

Then I tried with [Cross References], every possible combination:
[Part 1]({{< ref “part-1” >}} “Part 1”)
[Part 1]({{< relref “part-1” >}} “Part 1”)
[Part 1]{{< ref “2020-11-10-new-blog-post/part-1” >}} “Part 1”)
[Part 1]{{< relref “2020-11-10-new-blog-post/part-1” >}} “Part 1”)

apparently hugo always errors out and I’m not able to run the server:

$ hugo server -D
Start building sites …
ERROR 2020/11/18 10:05:41 [en] REF_NOT_FOUND: Ref “adding-users”: “/home/user/Projects/testproject/content/post/2020-11-10-new-blog-post/index.md:21:16”: page not found
Built in 317 ms
Error: Error building site: logged 1 error(s)

How can I get this thing to work?
I maybe doing something wrong? What would be the expected workflow to achieve this result?
From my understanding of Page Bundles, the use case is exactly when you want to keep page resources together, and page resources can be images or other pages. Am I missing something?
Any other suggestions to overcome this problem would be appreciated.

$ hugo version
Hugo Static Site Generator v0.78.1/extended linux/amd64 BuildDate: unknown

Thanks,
Nicola

You need to rename new-blog-post/index.md to new-blog-post/_index.md, notice the _.

index.md indeed makes this a leaf bundle, which means that content from non-index page files are accessed only as Page Resources, ie not as their own pages. As a page-type Page Resource, part-x.md has no .Permalink : https://gohugo.io/content-management/page-resources/

Hi there!

Thanks for quick reply. I’ve read about Branch Bundles, but for me is not clear:

content from non-index page files are accessed only as Page Resources

What would be this use case? What exactly means and how can someone access a .md file as a page resource if it doesn’t have a permalink?

You can access their .Content,

{{ (.Resources.GetMatch "foo.md").Content }}
1 Like

Thank you @pointyfar