Test static site generation
Introduction
This small snippet aims to convince that you can render all static pages at once using SSG-scheme.
OK, what should I see?
Scheme is as follows:
- Aim is to deliver plain ol' HTML pages by web server. No, no application server accepted; This is best for most of services!
- Problem: You have redundant content, and you don't want the hassle to maintain HTML files:
- No functions, so redundant code;
- Can't properly handle modular breakdown (header, footer, sections);
- When you made it work once, shall you re-understand everything 6 months later to thange stubs?
What should I open?
template/index.njkis a good start,- then
settings.yml, - Then run the script and see the
public/index.htmlfolder. It explains it all.
Here is how it works:
- We store relevant data in a YAML file, say
settings.yml. - We Use Nunjucks, the millenials way to code, to generate Jinja2-styled webpages on steroids.
- We Then compile the whole once, and after we got static HTML in
public/folder for basically every use.
What this repo doesn't contain:
- All Nunjucks killer features.
Dependencies
Install NodeJS and npm
Build
npm install
Serve your webserver to display the public folder as webroot.
Description
Languages
JavaScript
86%
HTML
14%