Templating
Under the hood, Kask uses Go templating engine. Thus, developers can refer to the official text/template documentation for topics not covered by Kask documentation.
Page templates
Templating content
Kask provides a series of useful, dynamic information to templates at the moment they are opened for rendering to static HTML. The struct provided to template file is called TemplateContent
, which contains many fields:
type TemplateContent struct {
Stylesheets []string
Node, Root *Node
Markdown *markdown.Page
Time time.Time
}
- Node (sitemap item) information:
- Title of node, extracted from the source file’s name, or the
H1
tag of markdown file if available. - Href for other pages to link.
- Children, which is a list of
Node
s.
- Title of node, extracted from the source file’s name, or the
- Root information:
- The root
Node
of the website, typicallyhref
s to the/
of website. This is usefull to start printing a sitemap. Just define a recursive template.
- The root
- List of stylesheets for template to include in
<head>
. See Hierarchical CSS Splitting - Date in Go
time.Time
type. Useful to print the year to footer.