Main block not rendered in custom archetype's layout

My theme’s index uses baseof.html that calls for main block. But Hugo can’t seem to find this if I call main block from a custom archetypes layout. Specifically, from projects/list.html or projects/single.html. Why is it like this?

Full repo here

Folder structure:

└── space
    ├── archetypes
    │   ├──
    │   └──
    ├── layouts
    │   ├── 404.html
    │   ├── _default
    │   │   ├── baseof.html
    │   │   ├── list.html
    │   │   └── single.html
    │   ├── index.html
    │   ├── partials
    │   │   ├── footer
    │   │   ├── head
    │   │   ├── header
    │   │   ├── home
    │   │   └── projects
    │   └── projects
    │       ├── list.html
    │       └── single.html
    ├── static
    │   └── assets
    │       ├── css
    │       ├── fonts
    │       ├── img
    │       └── js
    └── theme.toml

Thanks for your help!


Both your list.html and single.html only have partial calls and don’t include a main definition.

Try wrapping both of those templates in {{define "main"}}{{end}}.

@rdwatters hmmm the partial and contents are wrapped with main … took the inspiration from your theme :slight_smile:

Check out this code, not in master branch

Yeah, i was looking here when running locally. One moment:

Remove the whitespace - from the "main" definition. Works for me locally:

Oh maan … whitespace! why whitespace is causing this lol :disappointed_relieved: … and ouch the images are gone too
Thank you so much for helping @rdwatters!

Oh okay got it, so now each image should be pointed to the correct folder, such as like this <img alt="Image" src="{{.Site.BaseURL}}img/projects/001/work-8.jpg">

In a way, it might be helpful to split the statics used:

  • theme’s static should be put under themes/THEME_NAME/static/assets
  • site content’s static should be put under site’s root static

Nice! now I really excited to move forward! :smile:

Hugo uses the “define” to identify if a template needs a base template. I have improved the detection to handle your syntax in the future:

1 Like

I see… that’s a good thing … :slight_smile: !

Btw, @bep … if in localhost this page can render properly http://localhost:1313/projects/,
why it doesn’t work after deployed into Netlify https://improve-asset– ?

I’m confused with this behavior

And that is the poor man’s regular expressions – but o so much faster.

Update: I removed all dashes - and put Hugo version 0.26 in context. Now the list.html seems to work! :tada:

Thanks a lot for your help @bep!

1 Like