Static Site Generation

What is a static site generator

A static site is a collection of pages contained in basic HTML files. You could hand-write these in a text editor, but managing assets and repeated elements such as navigation can become problematic.

A content management system (CMS) stores page content in a database and provides facilities to edit and apply themes. Management becomes easier at the expense of flexibility, performance, server requirements, security and backups.

A static site generator (SSG) is a compromise between using a hand-coded static site and a full CMS. You generate an HTML-only website using raw data (such as Markdown files) and templates. The resulting build is transferred to your live server.

Source: Sitepoint


What is JBake ?

JBake is a Java based, open source, static site/blog generator for developers & designers.

  • Supports AsciiDoc, Markdown and good old HTML formatted content
  • Structure your content any way you see fit
  • RSS feed, archive and tag support
  • View draft content before publishing it and making it available to the world
  • Freemarker, Groovy, Thymeleaf & Jade based templates & scripting support
  • Easily integrate CSS frameworks such as Bootstrap and Foundation
  • Add as much metadata to content as you like, also exposed to templates
  • Store your site content in Dropbox, CVS, SVN, Git or whatever you want

Source: StaticGen


What is Thymeleaf ?

Thymeleaf is a modern server-side Java template engine for both web and standalone environments.

Thymeleaf's main goal is to bring elegant natural templates to your development workflow — HTML that can be correctly displayed in browsers and also work as static prototypes, allowing for stronger collaboration in development teams.

With modules for Spring Framework, a host of integrations with your favourite tools, and the ability to plug in your own functionality, Thymeleaf is ideal for modern-day HTML5 JVM web development — although there is much more it can do.

Source: Thymeleaf home page


Advantages of generated static websites

No database, no server side scripting, just plain files

Often your provider provides you some free web space. However, this web space only allows static files.

A static site generator offers a solution. You can generate your complete site off line, in a dynamic way and then upload the generated site to your provider.

No database needed, no need for backups ! When you want to switch to another server, just copy the static files.


Speed and performance

As all files are already generated, the speed to deliver the content to the viewer is optimal. No round trips to a database, no dynamic creation of the page.

As the file is generated on disk, you can run a full optimization on the content, even shrinking it more by removing whitespace, ...


Scaling

As the site is static, deploying it on multiple web servers and putting a load balancer in front of it is a piece of cake. If you need more capacity, just add an instance. This is perfect also for containers.


Clean separation of environments

A common problem with solutions like WordPress is that the content is stored in a database. There's no easy way to copy content between databases, so most likely the content writers will update the content straight in production. You need a complete management system surrounding solutions working like this.

With static site generators, your sources are on disk. You can put them in Git and use GitFlow's approach with branches to separate the content between development, pre-release and production.


Limitations of generated static websites

No default solutions for user interaction

As everything is static, there's no solution without third party solutions for interaction with the readers. It's easy to solve, but not with the static site generator itself.


Not suited for webshops or e-commerce (yet?)

Typically, webshops use too many features like cross-selling that are not a match for static generated sites.

See also: Sitepoint: 7 reasons not to use a SSG


How can Asynchrone help with Static Site Generation ?

Building a site with JBake + Thymeleaf

Only recently Asynchrone discovered the power of JBake and Thymeleaf. But as they are both based on technology commonly used by Asynchrone, Asynchrone is confident that it can provide services for those products. Asynchrone can develop your site.

Asynchrone is about code. Not about graphical design. We will either partner with designers or we need a design created by the customer for this part of the solution.


Setting up a Gradle project to build and publish

Asynchrone can of course provide a more professional approach to building the site. View the actual build.gradle file used for building this website with JBake.


Setting up GitLab/GitHub and Nexus

Asynchrone can provide the knowledge for storing the sources, using branches for deployment in different environments and creating the artifacts. Asynchrone also has a docker image for deploying sites using JBake.


Examples

This website is fully built with JBake. The code is open sourced on GitHub to provide insights on how the development works.

Another example is Yves Vindevogel's personal blog site. The code is also open sourced on GitHub.


More information

Page last updated on: 2018-09-10