- This is a fork from https://github.com/wzulfikar/nunjucks-starter-kit I updated all dependencies, and changed the gulp file a little.
- I swapped Bootstrap https://getbootstrap.com/ for Bulma bulma.io/
- I added the bulma SASS source, so you can comment out parts you don't use, then recompile the bulma CSS file.
- I renamed all Nunjuck files to .njk to make it clear they're template files.
-
download & unzip: https://github.com/benninkcorien/nunjucks-starter-kit/archive/master.zip or
git clone https://github.com/benninkcorien/nunjucks-starter-kit.git
- install dependencies: run
yarn install
to install everything listed in package.json - run
gulp bulma
to compile bulma from node_modules to dist/assets/css/bulma.css - run
gulp auto
. this will launch browsersync and watch for changes etc. - try changing one of the pages inside
src/pages
& your browser will auto-reload, displaying the change you just made.
Run
gulp minify
if you want to minify your html files insidedist
folder
- works out of the box!
- example included (using bulma css):
src/pages
for page contentsrc/templates
for page layout
- output is plain html (stored in
dist
directory) - serverless
- can use free service like surge.sh, github pages for hosting
- minimum knowledge needed: html, css, js – no need for php, ruby, etc.
- minifier included! use
gulp minify
Here is the project structure:
dist
: this directory contains real files that will be hosteddist/assets
: all css, js, images, fonts and whatever assets related to app are located heresrc
: raw files used to develop the appsrc/pages
: pages for the app, everything here will be rendered todist
directorysrc/templates
: layout filessrc/templates/partials
: partial files like nav, user-tabs, menu, etc
A. without auto-render
- edit pages in src
- run
gulp
- publish
dist
to hosting provider
B. with auto-render
- run
gulp watch
- as you edit src, dist gulp watch will do the rendering behind the scene n updates dist directory: you need to reload your browser to see the changes
- publish dist to hosting provider
C. with auto-render & auto-reload (via browsersync)
- run
gulp auto
- it will open
http://localhost:3000
in your browser - using this workflow, when you edit
src
thedist
will be updated (just like workflow B) and your browser (http://localhost:3000
) will be reloaded automatically.
{% set title = 'Page title' %} used in <title> tag
thenav.active('pagename')
{% block nav %} {% import 'macros/nav-macro.njk' as thenav %} {{ thenav.active('about')}} {% endblock %}
Added automated CSS/JS version numbering (via gulp).
Nunjucks official docs: https://mozilla.github.io/nunjucks