Static site generation on the JVM with JBake
Static site generation on the JVM with JBake
Talk
- Explain what baking a web site is
- Overview of JBake
- Demonstration of main features
Introduction
- Java web developer for CGG
- Creator of JBake
- Part-time Student
Building a static web site from simple text files ...
... a popular alternative to frying a web site using a database.
Benefits
- Performance
- Security
- Platform independence
- Version controlled content
- Use your favourite text editor/IDE
Background
- Project started back in 2013
- Created to 'scratch an itch'
- Inspired by 'Blogging like a hacker' article
...just a hobby, won't be big and professional...
Features
- Java (JVM benefits)
- Open source
- Content structure freedom
- Supported content formats...
- Markdown
- AsciiDoc
- Raw HTML
Features
- Blog aware
- Draft publishing support
- Front-end framework freedom...
- Bootstrap
- Foundation
Templates
- Templates enable content reuse
- Provide dynamic nature
- Supported Template engines ...
- Freemarker
- Groovy
- Thymeleaf
- Jade
- Content data model exposed to templates
Installation
- Download from jbake.org
- Also available through...
- SDKMAN!
- Homebrew
- Maven Central
- Runtime requires just a JRE
Usage Options
- Command line interface...
- init
- bake
- serve
- Maven plugin
- Gradle plugin
- Java API
How the "oven" works
Site/Project layout
├── assets
│ ├── css
│ ├── img
│ └── js
├── content
│ ├── changelog.md
│ ├── news
│ │ ├── index.md
│ │ └── jbake-v2-1-released.md
│ └── sites.md
├── templates
│ ├── index.ftl
│ ├── page.ftl
│ └── post.ftl
└── jbake.properties
Content file - Markdown
title=Changelog
date=2013-03-30
type=page
status=published
~~~~~~
### v2.1
*2013-04-30*
* Added unit tests
* Added post baking stats
* Command line arguments are now optional
...
Template file - Freemarker
<#include "header.ftl">
<#include "menu.ftl">
<div class="page-header">
<h1>Blog</h1>
</div>
<#list posts as post>
<#if (post.status == "published")>
<a href="${post.uri}"><h1>
<#escape x as x?xml>${post.title}</#escape>
</h1></a>
<p>${post.date?string("dd MMMM yyyy")}</p>
<p>${post.body}</p>
</#if>
</#list>
Template file - Jade
doctype html
html
include header.jade
body(onload="prettyPrint()")
div#wrap
include menu.jade
div.page-header
h1 Blog
each post in published_posts
a(href="#{post.uri}")
h1 #{post.title}
p #{formatter.format(post.date,
"dd MMMM yyyy")}
p !{post.body}
Config file
site.host=http://jbake.org
render.tags=false
render.sitemap=true
template.masterindex.file=index.jade
template.archive.file=archive.jade
template.tag.file=tags.jade
template.sitemap.file=sitemap.jade
template.post.file=post.jade
template.page.file=page.jade
template.feed.file=feed.jade
Time for the Demonstration