I'm looking for a way to provide templates that override the page.ext
templates for specific pages, and wondering if you'd be willing to
accept a patch?
For example, if I have about.html and projects.html, they both
currently derive from the templates page.html and base.html.
However, I'd like them to derive from different templates.
I propose that if a template exists with the same name as the file,
that template would apply to the page instead of the default page.ext.
Therefore, creating a template about.html in my example would cause the
about page to derive from about.html and base.html. If there is no
projects.html template, the projects page would still derive from
page.html and base.html.
On Fri Jul 1, 2022 at 12:05 PM EDT, Edd Salkield wrote:
> I'm looking for a way to provide templates that override the page.ext> templates for specific pages, and wondering if you'd be willing to> accept a patch?>> For example, if I have about.html and projects.html, they both> currently derive from the templates page.html and base.html.> However, I'd like them to derive from different templates.>> I propose that if a template exists with the same name as the file,> that template would apply to the page instead of the default page.ext.>> Therefore, creating a template about.html in my example would cause the> about page to derive from about.html and base.html. If there is no> projects.html template, the projects page would still derive from> page.html and base.html.
Interesting idea. However, this doesn't work well with the way that
templates are currently laid out. What happens if I have a page named
"page.ext"? For this to work, the built-in templates would need to be
renamed to "_index.ext" and "_page.ext" so that they can't conflict with
existing pages. That would be a breaking change, so we would probably do
this in a 0.4.0 release.
Another idea would be to add a new frontmatter option to specify which
template to use. For example:
---
title: About me
template: about
---
kiln would then look for about.ext in the templates directory using the
same logic it uses for other templates. I think this idea might be nicer
since it is not a breaking change and allows multiple files to use the
same template. What do you think?
I have the same problem with creating about-page. Currently I have
"templates/page.html" (for about-page) and
"templates/_default/page.html" (for posts), and "content" folder
contains "posts" subfolder and "about.gmi". That's not quite clean
workaround as for me and I would like to get rid of posts subfolder (and
have all gmi docs in content folder), so some sort of per-page templates
would be nice feature!
On Sun Oct 2, 2022 at 10:34 AM EDT, Edd Salkield wrote:
> I've written a patch to add the template frontmatter override behaviour:> https://lists.sr.ht/~adnano/kiln-devel/patches/35769
Funny, I just pushed a similar commit yesterday.
Ah, I really should have checked this before I started working on it!
I've rebased my changes on top of the latest commit, so that at least we
can benefit from the error handling. Will send a patch shortly.