~adnano/kiln-discuss

2 2

Per-page templates

Details
Message ID
<CL4G4GYOW3HQ.1C3N1D168B7FP@henleybeach>
DKIM signature
pass
Download raw message
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.
Details
Message ID
<CL7170G8FRMR.3F7GMDEDEH1HI@nitro>
In-Reply-To
<CL4G4GYOW3HQ.1C3N1D168B7FP@henleybeach> (view parent)
DKIM signature
pass
Download raw message
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?
Details
Message ID
<b193e37e-946a-dd36-c163-5bab4c7406a3@disroot.org>
In-Reply-To
<CL7170G8FRMR.3F7GMDEDEH1HI@nitro> (view parent)
DKIM signature
pass
Download raw message
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!
Reply to thread Export thread (mbox)