~adnano/kiln-discuss

5 3

Per-page templates

Details
Message ID
<CL4G4GYOW3HQ.1C3N1D168B7FP@henleybeach>
DKIM signature
missing
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
missing
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
missing
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!
Details
Message ID
<CNBIG54EU8GL.15XQUSH1IF36H@henleybeach>
In-Reply-To
<CL7170G8FRMR.3F7GMDEDEH1HI@nitro> (view parent)
DKIM signature
missing
Download raw message
I've written a patch to add the template frontmatter override behaviour:
https://lists.sr.ht/~adnano/kiln-devel/patches/35769
Details
Message ID
<CNBPAF2HTBEZ.1ZCC5N8D3673S@framework>
In-Reply-To
<CNBIG54EU8GL.15XQUSH1IF36H@henleybeach> (view parent)
DKIM signature
missing
Download raw message
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.
Details
Message ID
<CNC8QAUXSLHX.1PDNHR236CWX@henleybeach>
In-Reply-To
<CNBPAF2HTBEZ.1ZCC5N8D3673S@framework> (view parent)
DKIM signature
missing
Download raw message
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.
Reply to thread Export thread (mbox)