Can't make baseof + blocks templates work


#1

I have _default/baseof.html defined with

header...
{{ block "main" . }}

{{ end }}
footer...

inside of it.
As soon as I modify a template, say home.html, from {{ .Content }} to

{{ define "main" }}
  {{ .Content }}
{{ end }}

the template is not working any more, I’ve got a function "page" not defined error, any idea why?


#2

Some of the pages using your block main may mot have e.Content available.
It’s hard to help without the repo though.


#3

The page using baseof.html + home.html is content/_index.md and contains only “home”. I am initiating Hugo so I have dummy files to test it.
Here is the repo but I don’t think you need it as my question is about very basic behavior and not bound to my content since I don’t have content (I just put “home” to test)…


#4

I assume you have errors in your log?

The very first template code looks wrong. Scrolling down I see more errors. Go template code are not very forgiving; you have to type exactly the right commands and function names etc.


#5

Oh yes, it’s because I copied the code from Jekyll without adapting to Hugo, just to test the layouts system. I thought at least it would output something weird, but Hugo doesn’t output anything… When removing Jekyll snippets it outputs something. Unforgiving as you say ^^ Thank you.