Images on home page: range

I have a collection of images that I have in content/images
under themes I have layouts/index.html. I have a matching _index.md in content/ that I do not think is relevant. (?)

In my index.html I have the code:

      {{ range .Resources.Match "images/*.jpg" }}
      {{ . }} <br/>
      {{ end }}

I thought this should loop over all the images in the images directory. At the very least I would see the </br> in the page source. But I do not.

I am barking up the wrong tree some where. What am I doing wrong?

I can make it work, sort of, like this:

        {{ range (readDir "content/images/") }}
        <img src="images/{{  .Name }}" />
         {{ end }}

But I should be using the concept of Resources, shouldn’t I?

In the Page Bundles doc: Page bundles | Hugo

Under β€œWhere can the Resources live?” for Branch Bundles:

Only in the directory level of the branch bundle directory i.e. the directory containing the _index.md

Thank you
What is the difference between leaf and branch bundles?

    Leaf Bundle (leaf means it has no children)
    Branch Bundle (home page, section, taxonomy terms, taxonomy list)

I am not sure what has no children means in this context.

A Leaf Bundle is a directory at any hierarchy within the 
content/ directory, that contains an index.md file.

and

A Branch Bundle is any directory at any hierarchy within 
the content/ directory, that contains at least an _index.md file.

Is the difference the _ character appended to the front of the index file? I missed that until I was writing this…

The _ (or lack thereof) before the index.md is what signals whether it is a leaf or a branch bundle.

β€œNo children” means there are no pages nested under it:

content/food
└── desserts              # branch bundle
    β”œβ”€β”€ _index.md
    β”œβ”€β”€ ice-cream         # leaf bundle
    β”‚   └── index.md
    └── pies              # branch bundle
        β”œβ”€β”€ _index.md     
        β”œβ”€β”€ apple-pie     # leaf bundle
        β”‚   └── index.md
        └── pecan-pie     # leaf bundle
            └── index.md

Ok. But why? Is there a reason for the difference in the bundles, and is there a reason to swing so much over _index V. index? I am not sure I can see why leaf and the branch bundle need to be so different. I definitely do not see why the index file needs to be different.

I see the children applies to the directory. That makes sense.

I am a bit disturbed having to dump all my files into content/ (rather than tidy them away to content/images) to have them available to the home page.

I am new. Am I doing it wrong?
My home page wants to be heavy with images, it is a artists boasting site.

The question really is what site structure do you want Hugo to generate for you?

Consider my example above. In that state, Hugo will generate

example.com/food/desserts/pies/apple-pie/
example.com/food/desserts/pies/pecan-pie/

because pies is a branch bundle. If you turn it into a leaf bundle, then the navigable pages end at example.com/food/desserts/pies/.

You can use headless bundles: Page bundles | Hugo

1 Like