Closed timokleemann closed 3 months ago
Every path you reference via include
or via .render
calls must be within the search paths you configure for the engine.
Somewhere you may have a line like, nunjucks.configure('partials')
to set the view directory; change it to nunjucks.configure(['./partials', './images'])
and then include the path relative to that; eg {% include "./logo.svg" %}
Thanks. I managed to get it to work by changing my Gulpfile
accordingly:
const { src, dest, series, watch } = require('gulp');
const njk = require('gulp-nunjucks-render');
function createHTML() {
return src('src/html/pages/*.+(html|njk)')
.pipe(njk({ path: ['src/html', 'src/images'] })) // <-- Added a second path to the array here!
.pipe(dest('dist'));
}
Hi,
Is there a reason why this is giving me a
template not found
error?If I put the
logo.svg
in the same directory as myheader.njk
partial, the SVG gets loaded without any problems:I would like to store the SVG in my
images
folder, though, not in mypartials
folder. How can this be done?