Hugo ignoring list.html/hierachy

My website works just fine.

So I’ve been trying to add a new section.
/Artwork/art
/Artwork/work

there are clickable images on the /artwork/ page
that take me to the respective /art/ and /work/ subdirectories.

But for the life of me, I can’t link the /artwork/ page to the /work/ page.
I’ll click the image, be directed to the page via the url, but be served the very same content from the /artwork/ yet on the /work.

But /work/ is a completely different page.
I’ve overlooked something.

I’ve not done anything for the /art/ page, so it doesn’t exist, and u can ignore it. Just focus on the /work /page

├── config.toml
├── layouts
│   ├── _default
│   │   ├── baseof.html
│   │   ├── list.html
│   │   ├── redirect.html
│   │   └── single.html
│   ├── artwork
│   │   ├── art
│   │   │   └── list.html
│   │   ├── list.html
│   │   └── work
│   ├── diary
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   ├── movie
│   │   ├── list.html
│   │   └── single.html
│   ├── section
│   │   ├── artwork
│   │   │   ├── art
│   │   │   │   └── list.html
│   │   │   └── work
│   │   │       └── list.html
│   │   └── redirect.html
│   └── shortcodes
│       └── video.html

My hunch is the issues lie in my Layouts/_default, Layouts/artwork, & Layouts/section

Here’s a repo to my full build where you can test it.
https://github.com/konzuko/hugosite

Appreciate any support you can give.

There’s nothing like a hierarchy for layout templates. and there’s no one shot subsection templating.

So you cannot address deeper stuff with a folder structure in the layouts folder.
for details have a look at Template lookup order | Hugo

What you could do is target a specific template using a frontmatter field layout.

  • change your content/artwork/work/_index.html content to:

    ---
    title: "Work Section"
    layout: "work"
    ---
    
  • create the layout for that work folder as layouts/artwork/work.html

A tips is to look in to “Cascade” in Front matter | Hugo if you want to set it for a whole section.

You can set it as a cascade value on _index.html and all files in the section will pick it up.

I also prefer to set “type” instead of “layout”, but that is more a preference.

An important note here is that the glob pattern used when setting type can be used to target a certain level, which can be used to “style” a sub section.

2 Likes

With the comment from @bep:

set the layout for the sections in hugo.toml:

[[cascade]]
   [cascade._target]
    path = '/artwork/work'
    [cascade.params]
      layout = "work"
[[cascade]]
   [cascade._target]
    path = '/artwork/art'
    [cascade.params]
      layout = "art"

then no setting in front matter is necessary and you may add arbitrary subsections just central in the config.

Appreciate the help, homies. Fixed it by literally renaming and moving the files in accordance to the cascade style.

The cascade method made it simpler, helping me debug the issue, deleting redundant sections too.

This is how it looks now

# Cascade configurations
[[cascade]]
  [cascade._target]
    path = "/artwork/work"
  [cascade.params]
    layout = "work"

[[cascade]]
  [cascade._target]
    path = "/artwork/art"
  [cascade.params]
    layout = "art"

[[cascade]]
  [cascade._target]
    path = "/artwork/"
  [cascade.params]
    layout = "list"

and i added this to my config.toml

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.