Suggestions for content type

Greetings!
I am new to Hugo but have a background in Django, Rails etc. I am trying to build a very simple website that has 3 types of lists:

  • People (with various attributes including a photo),
  • Sponsors (with a full name, abbreviation and url)
  • Publications (with name, authors, date and sometimes a PDF)

Two of these 2 types have associated resources.

I am thinking that they could all be driven from data files (since these aren’t ‘pages’, they are just lists. However, I am not sure where the resources would go…

It took me forever to figure out that for each ‘person’ to have an image, I would need to structure my content like this:
content/people/
├── Fred
│ ├── index.md
│ └── Fred.png
├── Geno
│ ├── Geno.jpg
│ └── index.md
├── _index.md
└── Tim
└── index.md

But this approach seems like overkill. We don’t need a page for every piece of content…

How could I associate a PDF file with each publication in a list, or an image with a person, without creating a directory structure?

Many thanks for the advice!

One (potentially naive) approach: in content/people/_index.md you could add some custom front matter. Then loop through that front matter. Roughly something like:

params:
  data:
    - name: Fred
      img: img.jpg
    - name: Geno
      img: img.jpg

Am curious what other members would suggest.

Thanks for the suggestion!
With this approach there is only one sub-directory and all the images are right there within it.

I like the simplicity of the approach!

People also have a ‘association’ label [Faculty, Researcher, Alumi…], and the listing would need to be ordered by ‘association’. Do you think that I could extend your approach to meet that use case?

I think so. First add the association entry to each map:

params:
  data:
    - name: Fred
      association: Faculty
      img: img.jpg
    - name: Geno
      association: Alumni
      img: img.jpg

Then order by it:

{{ range (sort .Params.data "association") }}
...

See the sort docs for more power: https://gohugo.io/functions/sort/#readout

1 Like

Excellent!
So grateful for your advice!

I am having some troubles getting the desired results, so I have been scaling it back to see where the error is.

on layouts/people/list.html:
{{ range .Site.Params.authors }}
- {{ .lastName }}-
{{ end }}

and in config.toml
[params.authors]
[params.authors.Derek]
“firstName” = “Derek”
“lastName” = “Perkins”
[params.authors.Joe]
“firstName” = “Joe”
“lastName” = “Bergevin”
[params.authors.Tanner]
“firstName” = “Tanner”
“lastName” = “Linsley”

and even though there is the correct number of loops, there is no content displayed (only dashes).

I feel like this could be a great direction to take this simple project, and I am just missing a small something.

Thank you for any community advice!

My TOML table nesting isn’t up to par. Personally I would write it in YAML or JSON as I find those easier to understand what’s going on.