Help with Headless Bundles


#1

Could anyone help me with getting headless bundles to work …

I have properly setup my page as a Leaf Bundle with resources however when I mark my content index.md files as a headless bundle ( headless : false) then the range statement does not work correctly .

my code

{{ range first 6 (where .Site.Pages "Section" "in" (slice "logos")) }} 
{{ $image := .Resources.GetMatch "*.png" }}
{{$title := .Title}}
{{ with $image }}
{{ $scaled := .Resize "1024x" }}
<img class="img-fluid" src="{{ $scaled.Permalink }}" alt="{{$title }}">
{{ end }}
{{end}}

#2

If my memory serves me correctly: Headless means that it

  1. Is not represented by an URL (no Permalink)
  2. It is not available in .Site.Pages etc.

You can, however, get to it by .Site.GetPage.

Which was kind of the intended usage. E.g. a headless bundle you know where is.


#3

Your question is not clear… you want to use headless bundles, but then you set it to false?

I have a test here; see if this helps.

  • Refer to the Markdown and Layout file source links on that page to understand the headless bundle concept better.
  • Source of the headless bundle index.md.

The best way to help with this is if you share your site source.


#4

I apologize I was only able to get the code to work by setting headless to false

That was the actual code

I guess my question would is there a way to range over all the leaf bundles in a section as in an image gallery you could just keep adding leaf bundles of content and images in a designated section…

My project is right here https://github.com/fieldingtron/freelancer-hugo but as I said I was unable to range over headless bundles


#5

no…