Section Resources

I’m trying to implement different headers for sections using the .Resources function.

Right now my _index.html has this in the frontmatter:

/content/instagrams/_index.md

---
aliases:
 - /instagram
resources:
- src: images/ingo-ellerbusch-719693-unsplash.jpg
  name: "header"
options:
  unlisted: false
  showHeader: true
---

But when I try to fetch any .Resources map, it turns out empty. I have a workaround for this, but using resources would be much cleaner.

{{ .Resouces }} and {{ .Page.Resources }} both return []

so, am I missing something or is using resources in _index.md not possible?

Hey Bruno,

You need to have that image file alongside _index.md (in the same bundle) in order for it to be a Page Resource. Is it the case?

If not: The resources param in the Front Matter simply allow to assign meta data to a Page Resource, it does not allow to assign a Page Resource to a page. Only placing the file in the bundle can do that.

Thanks @regis. Well the file is in content/instagrams/images/and when I moved it to content/instagrams/it worked. :slight_smile:

So if I understood correctly, Section Resources can’t be inside sub-folders.

Correct, the doc has a comparative table about the differences between Leaf Bundle and Branch Bundle (Section Bundle):

Correct. That gets ambigous pretty fast. I guess we could probably support it, but this limitation makes it much simpler – we don’t have to traverse down the file tree to see if there is a nested section somewhere down there …

I would actually suggest you keep it this way. It’s already hard enough for me to distinguish between taxonomy and section, making them behave more like page bundles would just make it a bigger mess in my head.

Just to close the loop of this story. After understanding the difference between taxonomies and sections, I went back to my code and was able to rewrite a bunch of nasty hacks that I had for organising the content into “stories”.

The end result was a theme that now supports different headers for each section and more flexibility in having different layouts for them as well. Such as https://brunoamaral.eu/instagram/2018-11-25-19.45.18-1920614554260000048_653098/

I must have done something wrong in the instagram/single.html file because it takes 4 minutes to render, but that is a problem for another time. Thanks again guys! :smiley: