Hugo fails to render section; Hugo server renders it when _index.md is touched

I have a simple site for which the Hugo command fails to render the content of the only section. It renders the home page correctly. I’ve used Hugo for other sites with no problems.

Repo: https://github.com/drh/web-drhanson

content/baldy_chutes is the section in question.

The same behavior happens when I run the Hugo server. But if I touch content/baldy_chutes/_index.md, the server renders the section (and the entire site) correctly. When I quit and restart the server, I must retouch _index.md again.

The hugo list all command shows only the home page:

% hugo list all
path,slug,title,date,expiryDate,publishDate,draft,permalink,kind,section
content/index.md,,David R. Hanson,2024-06-24T14:25:28-06:00,0001-01-01T00:00:00Z,2024-06-24T14:25:28-06:00,false,https://drhanson.net/,home,

When I build the site with hugo, nothing in content/baldy_chutes is rendered and there are no errors:

% hugo --logLevel=info
Start building sites … 
hugo v0.128.2+extended darwin/arm64 BuildDate=2024-07-04T08:13:25Z VendorInfo=brew

INFO  static: removing all files from destination that don't exist in static dirs
INFO  static: syncing static files to / duration 7.534ms
INFO  build:  step process substep collect files 57 files_total 57 pages_total 1 resources_total 56 duration 16.373166ms
INFO  build:  step process duration 17.853167ms
INFO  build:  step assemble duration 244.042µs
INFO  build:  step render substep pages site en outputFormat html duration 8.591958ms
INFO  build:  step render pages 1 content 1 duration 8.667375ms
INFO  build:  step render deferred count 0 duration 500ns
INFO  build:  step postProcess duration 3.125µs
INFO  build:  duration 26.860542ms

                   | EN  
-------------------+-----
  Pages            |  6  
  Paginator pages  |  0  
  Non-page files   | 51  
  Static files     | 41  
  Processed images |  0  
  Aliases          |  0  
  Cleaned          |  0  

Total in 39 ms

Notice that the 3rd and 7th log message say there’s 1 page, but the summary says there are 6.

Finally, here’s the environment info:

% hugo env
hugo v0.128.2+extended darwin/arm64 BuildDate=2024-07-04T08:13:25Z VendorInfo=brew
GOOS="darwin"
GOARCH="arm64"
GOVERSION="go1.22.5"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"

Solution: rename /content/index.html to /content/_index.html

note the underscore to turn it into a branch bundle

tr;tr
Your main problem is, that your Homepage is created with an index.html which turns it into a leaf bundle which may not have any decendent pages

if you enable --printUnusedTemplates you’ll see, that your layouts for the section are not used

WARN  Template _default/list.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\_default\list.html
WARN  Template _default/single.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\_default\single.html
WARN  Template baldy_chutes/baseof.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\baldy_chutes\baseof.html
WARN  Template baldy_chutes/list.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\baldy_chutes\list.html
WARN  Template baldy_chutes/single.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\baldy_chutes\single.html

using _index.html youl get:

PS C:\_repos\github\forks\web-drhanson> hugo -D --gc --logLevel debug --printPathWarnings --printUnusedTemplates
Start building sites …
hugo v0.128.2-de36c1a95d28595d8243fd8b891665b069ed0850+extended windows/amd64 BuildDate=2024-07-04T08:13:25Z VendorInfo=gohugoio

INFO  static: removing all files from destination that don't exist in static dirs
INFO  static: syncing static files to \ duration 48.0851ms
INFO  build:  step process substep collect files 57 files_total 57 pages_total 6 resources_total 51 duration 47.5847ms
INFO  build:  step process duration 48.6215ms
INFO  build:  step assemble duration 0s
INFO  build:  step render substep pages site en outputFormat html duration 28.1329ms
INFO  build:  step render pages 5 content 5 duration 28.6543ms
WARN  Template _default/list.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\_default\list.html
WARN  Template _default/single.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\_default\single.html
WARN  Template baldy_chutes/list.html is unused, source file C:\_repos\github\forks\web-drhanson\layouts\baldy_chutes\list.html
INFO  build:  step render deferred count 0 duration 0s
INFO  build:  step postProcess duration 0s
INFO  build:  duration 77.7974ms

                   | EN
-------------------+-----
  Pages            |  5

Second: touching any source file in content/baldy_chutes

I can reproduce this behavior with 128.2 and older versions.

  • if you touch the _index file → all pages are pages in that section are rendered
  • if you touch one of the page md files → only that page is rendered

touch in my tests was my = true to the frontmatter

for me that sounds like a bug in hugo server

might be something for @jmooring or @bep to sort out

Argh! I thought I was past this noob mistake. :disappointed: This is embarrassing because I did not make this mistake in the other sites I recently converted to Hugo (e.g., this one).

The touch behavior you describe is identical to mine. I’ve tagged yesterday’s push (5a5cbd8 on Sat Jul 6 14:22:59 2024 -0600) as touch-bug so @bep or @jmooring can clone the correct commit if they decide to investigate a possible server bug.

Many thanks,
dave h

1 Like

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