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
H1tag of markdown file if available. - Href for other pages to link.
- Children, which is a list of
Nodes.
- Title of node, extracted from the source file’s name, or the
- Root information:
- The root
Nodeof the website, typicallyhrefs 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.Timetype. Useful to print the year to footer.