---
docs/kiln.1.scd | 7 ++++++-page.go | 6 ++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/docs/kiln.1.scd b/docs/kiln.1.scd
index 42c0658..8a35356 100644
--- a/docs/kiln.1.scd+++ b/docs/kiln.1.scd
@@ -135,7 +135,7 @@ The following keys are supported:
*template*
Optionally specifies the name of the template to use when building this
page. If unspecified, defaults to "page" for regular pages and "index" for
- index pages.+ index pages. The template is then gound according to *TEMPLATE RESOLUTION*.
Example:
@@ -244,6 +244,9 @@ Fallback templates can be specified in the templates/\_default/ directory. These
templates will apply only when the required kind of template is not found in the
template directory.
+The template for a specific page can be overridden by setting the *template* key+in the page's frontmatter. See *FRONTMATTER* for more details.+For example, the page file content/blog/my_first_post.gmi will be rendered with
the template templates/blog/page.ext. If that template is not found, it falls
back to templates/\_default/page.ext. If that template is also not found, then
@@ -253,6 +256,8 @@ Base templates also follow the same rules. For example, the index template
templates/blog/index.ext inherits firstly from templates/blog/base.ext, and
then falls back to templates/\_default/base.ext if present.
+There is no override mechanism for base templates.+## PARTIAL TEMPLATES
Partial templates can be placed in the templates/\_partials directory.
diff --git a/page.go b/page.go
index b62fddc..8b3a566 100644
--- a/page.go+++ b/page.go
@@ -199,6 +199,9 @@ func (p *Page) process(cfg *Site, task *Task) error {
tmplName = "index"
}
tmpl, ok := cfg.templates.FindTemplate(p.FilePath, tmplName+task.TemplateExt)
+ if !ok && tmplName != "" {
+ return fmt.Errorf("failed to generate index page %q: template %q specified in frontmatter but not found", p.Path, tmplName)+ } if ok {
var b strings.Builder
if err := tmpl.Execute(&b, p); err != nil {
@@ -216,6 +219,9 @@ func (p *Page) process(cfg *Site, task *Task) error {
}
var b strings.Builder
tmpl, ok := cfg.templates.FindTemplate(p.FilePath, tmplName+task.TemplateExt)
+ if !ok && tmplName != "" {
+ return fmt.Errorf("failed to generate page %q: template %q specified in frontmatter but not found", p.Pages[i].Path, tmplName)+ } if ok {
if err := tmpl.Execute(&b, p.Pages[i]); err != nil {
return err
--
2.37.3