ericalli / static-site-boilerplate

A better workflow for building modern static websites.
http://staticsiteboilerplate.com
MIT License
1.73k stars 166 forks source link

Template engine? #14

Open acespace90 opened 5 years ago

acespace90 commented 5 years ago

Is it possible to use some template engine like Handlebars, Nunjucks or something else?

thegrandpoobah commented 5 years ago

https://webpack.js.org/plugins/html-webpack-plugin/ (which this project uses) can use templates fairly easily with some minor changes:

First install Handlebars (this is the one I enabled, not sure about the others):

npm install handlebars-lodaer handlebars --save-dev

Then update the HtmlWebpackPlugin to look for *.hbs files instead of normal *.html files:

https://github.com/ericalli/static-site-boilerplate/blob/master/config/webpack.plugins.js#L60

You'll also need to change the output from .hbs extension to .html extension on this line:

https://github.com/ericalli/static-site-boilerplate/blob/master/config/webpack.plugins.js#L66

And Webpack should do the rest.

(I'm going a bit by memory here, so a bit of fiddling might be necessary here)

acespace90 commented 5 years ago

Ok thanks I will give it a try.

mikejandreau commented 4 years ago

Hi, did you ever try incorporating some templating into SSB? This is super useful, and that's the only feature I feel is missing.