Can you range headless pages on a branch bundle?

So I know the idea of this sounds pretty counterintuitive. So here’s my use case: I have a customers branch bundle / taxonomy which contains some leaf bundles for each customer that contain their logo and front-matter. So my listing layout out is all built and is currently only pulling their logos and front matter (no .Content ), which is the way I want it for now until I have more time and can start adding content for each customer. But I dont want empty pages in the meantime.

So here’s my file structure

  • content
    • customers
      • _index.md
      • customer-1
        • index.md (headless = true)
      • customer-2
        • index.md (headless = true)

And for layouts/customers/list.html

{{ range $index, $page := where .Site.RegularPages "Section" "customers" }}
                        {{ .Render "li" }}
                    {{ end }}

Now this is works as long as the leaf bundles / pages aren’t headless.

But after many readings like this similar idea,this one, bep mentioning something similar, and the docs I tried a number of ways to get it working like this…

ranging on /customers/list.html

{{ $resources := (.Site.GetPage "section" "customers").Resources }}
        {{ $pages := $resources.Match "**" }}
        {{ range $pages }}
          <h3>{{ .Title }}</h3>
        {{ end }}

This doesnt fail or give any error, but it also doesnt return anything. It’s an empty object. I tried changing section to type and a number of littler variations but I can’t seem to get it to work.

What am I missing here? Is this even doable?

It’s not clear why you are using headless bundles here… it sounds like you want to keep those pages as draft until you put full content in them, but then you also want to publish those pages but not empty?

In any case, you have the headless bundle organization incorrect. Try this:

content
    customers
        _index.md
        customers-other 
            index.md (headless = true)
            customer-1-other.md
            customer-2-other.md

Now, you need to get the customers-other page using .Site.GetPage as you did in your example, and then getting resources from there will retrieve the customer-*-other page resources.

Hope this helps.

1 Like

Thanks for the feedback. Yeah I know what I’m doing is a little out of the ordinary, and you said it best, I was hoping to have “published drafts” which I can access their front-matter but not have the pages actually rendered (ie not given a permalink) until more substantial content could be flushed out.

Down the road I was hoping to have a mixture of headless and non-headless customer pages. Some of the non-headless pages would have more detailed information about the customer and documents like case studies etc., and the headless would simply be their logo, which doesnt warrant a rendered page but accessing their front-matter would be nice. That’s kind of the approach I was going for if that makes any sense.

End goal idea

content
    customers
        _index.md
        customers-1
            index.md (headless = true)
            logo.jpg
        customers-2
            index.md (headless = false)
            logo.jpg
            case-study.pdf
        customers-3
            index.md (headless = false)
            logo.jpg
            something-else.doc
        customers-4
            index.md (headless = true)
            logo.jpg

But now looking at how the bundle organization would have to be restructured, I’m not sure it makes sense to do this approach - it doesnt seem to be practical at all.