How does a static site generator like Jekyll work?
What I love abou Jekyll!
credit: Daniel Kinzler
There are a lot of static site generators out there. But how do they actually work and what are their advantages and disadvantages?
Jekyll lets you write content in a simple markup language like markdown, and generates html files from it, using a template system. You can then upload these html files to a web server and view them with your browser.
The advantage is that there is no code running on the web server. Which means it can be a very small and “dumb” web server, without any database or even PHP or other CGI support. It does not require much RAM or CPU tor run. And since it’S just static HTML, there are no security problems: there is no PHP script that could have security holes, no database that could be vulnerable to injections, etc. Even if the webserver itself is compromised, damage is minimal: you website might be defaced, but there’s no confidential data in the database, etc.
The disadvantage is of course: it’s static. You can not modify it through the browser. You can not post anything to it. It can not process data in any way. If you want to modify anything, change your text or template, re-genrate the site, and upload it again.
Oh, and if you do want to incorporate any dynamic content (like comments), it has to be provided from the outside somehow, which introduces a lot of issues.
I would recommend something like this only if you do not want any user generated content, and you don’t need to change your site very often. But for a simple presentation only site, it may be a good option, especially if web server capacity (and maintenance!) is an issue.
Advantages
- As the name suggests these are static sites, they don't have to fetch any content from the databases and render that data with their templates. So basically page loads fast.
- Static sites are secure and safe, a simple HTTP server can serve these pages. Since there is no application that generates these contents, there is nothing that can be compromised.
- Faster and easier development of your sites. You can preview the whole site while in development, something which general CMS doesn't allow. Now there is no difference between front end and back end development.
- These static site generators allows us to manage our content and templates with version control.
Disadvantages
- CMS provide a web based interface for creating your posts, so you can access and post from any machine but SSG require the full development environment.
- Getting started with SSGs require working knowledge of YAML, markdown and some other utilities. So mostly developers prefer these for writing tech contents.
- SSGs create mostly blog or portfolio like sites. If you want complex functionality then you have to look for appropriate plugins which may or may not be availabe in your preferred SSG.