Skip to content

One-off no-content templates in content directory #693

@ge0ffrey

Description

@ge0ffrey

I have a team.html page which list all our contributors.
That needs to get generated through an ftl template that reads from data/users.yml. There is no other html page like it, that would reuse this layout. It's a one-off template.

I have several other pages (download.html, documentation.html) that require a one-off template.
In fact, index.html is a natural one-off template. So is feed and archive (but post and tag are not because they create multiple output pages).

What I need to do now (workaround):

  1. Create a file content/community/team.html:
title=Team
type=community_team
status=published
~~~~~~
  1. In jbake.properties add:
template.community_team.file=community_team.ftl
  1. Create a file templates/community_team.ftl:
<#import "base.ftl" as base>
<@base.layout>
    <h1>${content.title}</h1>
    <#assign users = data.get('users.yml').data>
    <#list users as user>
       <p>${user.name}</p>
    </#list>
</@base.layout>

Proposal A) What I want to do:

  1. Create a file content/community/team.html.ftl:
title=Team
status=published
~~~~~~
<#import "base.ftl" as base>
<@base.layout title="Team">
    <h1>${content.title}</h1>
    <#assign users = data.get('users.yml').data>
    <#list users as user>
       <p>${user.name}</p>
    </#list>
</@base.layout>

The output filename is the template name without the ".ftl" suffix.

Similarly, content/blog/feed.atom.ftl and content/blog/feed.rss.ftl can create an Atom and RSS feed for a single website.

Requirements:

  • one-off templates should still be able to import macros and layout parent templates from the templates dir. A simple <#import "../../templates/normalBase.ftl" should work.
  • For one-off templates, content.body should not resolve to null, so these one-off templates can easily extend layout templates.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions