Subpages that render different pieces of data from same markdown file?

Hello,

I’ve been searching all over and reading all the docs, but I can’t figure out how to structure my content/layouts to achieve my goal. Maybe it is not possible within Hugo’s structure? Hoping someone can help.

I’m working on a website for an art gallery, and I want to have a main landing page for an artist, with sub-navigation to show different pieces of data from that artist’s content page.

For example, the layout might be something like this:

Joe Artist
Biography | Exhibitions | Press

[IMAGE GALLERY HERE]

In the joe-artist.md file I would have:

---
name:
  first: Joe
  last: Artist
main_image: img/1.jpg
image_gallery: 
  - img/2.jpg
  - img/3.jpg
  - img/4.jpg
  - img/5.jpg
bio: b. 1989 in Hugoville, IO
exhibitions:
  - exhibition 1
  - exhibition 2
  - exhibition 3
press:
  - article 1
  - article 2
---

I want to have the image gallery visible when the root /joe-artist page loads, but then have the links below the artist’s name navigate to /bio /exhibitions /press and load that content in place of the image gallery.

I figure I can load all that information onto the /joe-artist page and then hide/reveal the divs on click using javascript, but I wondered if there was a better way to do it within Hugo’s template/layout structure?

Thank you for your help!!

Perhaps this might better be achieved with a data file instead of front matter?

Oh interesting I hadn’t thought about that. I bet you’re right!

This is a very basic question, so apologies in advance, but do you know how would I set up the layouts/routing for subpages?

At the moment I have:

/layouts/artists

  • artists.html
  • single.html

‘/artists’ shows a list of the artists, and then ‘/artists/joe-artist’ is an individual artist page.

Then I’m hoping to have ‘/artists/joe-artist/bio’ to load the biography, and same for exhibitions (/exhibitions) and press (/press).

I’ve tried a few different approaches, but can’t get the structure correct for loading the correct layouts for subpages.

Thank you!

Oh actually I found this from bep https://github.com/bep/hugotest, which I should be able to reverse engineer. And then hopefully pull the content I need from data files, as you suggested.