Use a block directive when a shared Go HTML template needs a section that a page may override. `{{block "styles" .}}…{{end}}` defines the named section with default content and executes it at that position, passing the current data (`.`). An extending template can redefine `styles` to replace the default. section 9.1.5
Required and optional sections
A base template can invoke required `title` and `content` templates with `{{template "title" .}}` and `{{template "content" .}}`; each page must define them. A `styles` block supplies default CSS, while an empty `scripts` block leaves room for page-specific scripts without requiring them. Parse the base with each extending template separately when assembling different pages. section 9.1.5
Listing 9.11 A base template to inherit from
{{define "base"}}<!DOCTYPE HTML> #1
<html>
<head>
<meta charset="utf-8">
<title>{{template "title" .}}</title> #2
{{ block "styles" . }}<style> #3
h1 { #3
color: #400080 #3
} #3
</style>{{ end }} #3
</head> #3
<body>
<h1>{{template "title" .}}</h1>
{{template "content" .}}
{{block "scripts" .}}{{end}} #4
</body>
</html>{{end}} #5
The base template shows a default `styles` block, an empty `scripts` block, and required template invocations side by side. section 9.1.5
