Home.html is not inheriting from _default/baseof.html

I’ve created a layouts/_default/baseof.html with a {{ block "body" . }}{{ end }}, but my layouts/home.html is blank even if I define the body block as such:

{{ define "body" }}
Test
{{ end }}

If I add anything outside the block definition, it gets shown. What am I doing wrong?

You will need to show a test repository with full code for us to see why this is not working.

I was reducing my page to a bare minimum that reproduced the problem and found out that it happened because I had a HTML comment outside of the block. When I removed that comment and refreshed the page, it worked. Why does this happen?

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

<!-- Seemingly harmless HTML comment..that will break your layout at build -->
{{ define "main" }}
...your code here
{{ end }}

Your templates should NEVER have comments “outside” of the blocks. always put them inside of your defines or blocks. see @pamubay’s comment

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