Question about Block Template Lookup Order

Hi! Newbie of Hugo here. I’ve come up with some questions, hope someone could help me. Here is my repo, please use it if you wanna reproduce the issue.

First downloaded Hugo (v0.18.1), applyed hugo_theme_robust, and added a post as the tutorial did.

Then I wanted to try if the Block Template worked or not, so I did these:

  1. Duplicated /themes/hugo_theme_robust/_default/baseof.html, added something different from the original file (In my repo was <p>Hello baseof.html!!!</p>), renamed to post-baseof.html, and move to /themes/hugo_theme_robust/layouts/section/
  2. Duplicated /themes/hugo_theme_robust/_default/list.html, added something different from the original file (In my repo was <p>Hello post.html!!!</p>), renamed to post.html, and move to /themes/hugo_theme_robust/layouts/section/

Now I wanna know if the Block Template Lookup Order worked or not. If it worked, when I visit http://base_url/post, the page should showed “Hello baseof.html!!!” and “Hello post.html!!!”.

The docs page described the order. After some experiments, and it’s the result (Checked means worked, unchecked means not):

  • [ ] /layouts/section/post-baseof.html (Moved post-baseof.html to this path)
  • [ ] /themes/exampletheme/layouts/section/post-baseof.html (Moved post-baseof.html to this path)
  • [ ] /layouts/section/baseof.html (Rename post-baseof.html to baseof.html)
  • [ ] /themes/exampletheme/layouts/section/baseof.html (Rename post-baseof.html to baseof.html)
  • [x] /layouts/_default/post-baseof.html (Moved post-baseof.html to this path)
  • [x] /themes/exampletheme/layouts/_default/post-baseof.html (Moved post-baseof.html to this path)

(Didn’t try the last two because it will override the original baseof.html)

So, is it a bug, or I just misunderstood something?

We did a round of adjustments and testing on this in

https://github.com/spf13/hugo/issues/2783

I’m not giving any guarantees that there aren’t any on any platform, but there are automated tests for all variants running on Linux, macOS and Windows.

So, I suspect there is something iffy with your test setup/methodology.