Baseof.html, blocks and a blank page

Hi, I am trying to make a new theme for my personal website / blog, and thought I would use blocks in the baseof.html instead of building everything with partials. The problem is that Hugo doesn’t seem to render anything! Here is what I have tried so far:

/layouts/_defaults/baseof.html contains:

<!doctype html>
<html lang="{{ .Site.LanguageCode . }}">

<head>
    <meta charset="utf-8">
    <title>Test</title>
</head>

<body>
    
    {{ block "main" . }}
    <h1>Test</h1>
    {{ end }}

</body>

</html>

This produced no output, so I added this to the index.html:

{{ define "main" }}
<h1>Test!</h1>
{{ end }}

Still nothing, so I tried adding the same to list.html.

Am I missing something really basic? Probably :slight_smile:. Help?

EDIT: I use “hugo serve -D --disableFastRender”

Those code snippets should work; it’s difficult to say where the problem is without the full code. See this note in the docs if that helps solve your issue:

Code that you put outside the block definitions can break your layout. This even includes HTML comments. For example:…

This is all the code I have written, and I’m wondering if it is not enough. I do have one post under /content, but that’s it.

Some further info: I’m running Hugo v.40.30.0 under ArchLinux.
EDIT: Oh, and I have defined my theme in the config file.

Ok, so I tried a new hugo site with just those lines and it errored with:

LanguageCode has arguments but cannot be invoked as function

Remove the dot after:

<html lang="{{ .Site.LanguageCode }}">

1 Like

Yes, that worked!

Thank you so much for taking the time to test this. Now that I have a working theme, it’ll be easier to discover my mistakes as I move forward :slight_smile:

I did not get the error message you got. Did you pass some argument to hugo to get a more verbose error report?

I only did a hugo serve for this test. I’m on 0.41 though, and I don’t know myself if logging had changed from 0.40.3. And yes, there is a -v , --verbose flag you can use. Happy Hugo-ing :slight_smile:

1 Like