If you structure your layouts/_default/ like this:
baseof.html:
<!-- head, body balabala essential elements -->
<main>
{{- block "main" . }}{{ end -}}
</main>
list.html/single.html:
<!-- I want to add a license here at the beginning of the file -->
{{- define "main" }}
<!-- your code here-->
{{- end }}
Then, you probably can not find the _index.md in your content. If you have layouts/index.html like the list.html/single.html before, you will get an error as below:
console.warn('"head" or "body" tag is required in html to append livereload script. As a fallback, Hugo injects it somewhere but it might not work properly.');
So, how to add my license at the beginning of my block define partial.
{{/* This one line comment will not appear on the rendered page. */}}
{{/*
Neither will
this block
comment.
*/}}
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ range .Pages }}
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
{{ end }}
You can only place newlines and template comments before and/or after the block definition.