I want to deploy the site to different servers for testing, production etc. So defining a basepath by changing one variable or setting would be the prefered method. What is the best method to implement this?
Currently I have set a variable in layout file as follows.
{% set siteBaseurl = '/demo' %}
It is used everywhere else I define paths as follows
<img src="{{ siteBaseurl }}/images/logo.png" />
I found the perfect solution. As mentioned in the gulp-nunjucks-render package you can parse variables to the template via gulp task. Using dotenv you can get it from a single configuration file. Here's how I set it up
.env
gulpfile.js
layout.njk
Hope this helps