[resolved] Lookup order for single.html not working correctly

I have this structure, in my themes’ layouts folder:

├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
└── index.html
├── reviews
│   ├── list.html
│   └── single.html

Most pages correctly pull from the _default folder. If I go to url /reviews/ it correctly pulls the template reviews/list.html.

However, if I go to an individual review at the url /reviews/name-of-review/ it uses the _default/single.html template.

According to lookup order, I would expect reviews/single.html to take precedence over _default/single.html when in the context of the url /reviews/. Isn’t that correct?

GitHub here (linked to the layouts folder). I’m running Hugo v0.40.2

EDIT: Pretty sure I messed myself up by using type= too liberally in my original Mardown files’ front-matter. Now going through and cleaning that up, since Hugo uses that field so specifically. I’ll report back once I finish that work. (it won’t be fast: I am converting 5k old posts from JSON to TOML through a Python script that I’m currently refactoring)

The list page is under reviews so its type is reviews. Hence the reviews/list.html is applied correctly.

Your pages under content/reviews have their type set to Review manually in the front matter. There’s no Review/single.html.

You can either:

  1. Create Review/single.html (note that Review is case-sensitive so review/single.html will not work).
  2. Remove front matter from the pages under content/reviews so their type is now reviews (or set them manually). This means you also need to modify this line in reviews/list.html
    • From: {{ $paginator := .Paginate (where .Data.Pages "Type" "Review") }}
    • To: {{ $paginator := .Paginate (where .Data.Pages "Type" "reviews") }}

image

2 Likes

Aha! You’re confirming what my edit/note to my page above suspected, thank you!

1 Like

Yes you are right. I saw your edit after I posted. Being a lazy person I could not let my screenshot and typing go to waste :smiley:

1 Like