0
votes

I'm trying to add a header as a component to eleventy, the console gives an error that there is no such template: "Error: template not found: header"
Tried names for the header: header, 'header', header.njk, 'header.njk'
Where am I wrong?

Screens:

file eleventy.js

files location in project

trying to call my template

console error

1
I'm not seeing the issue. Is your code in a repo somewhere we can see?Raymond Camden

1 Answers

1
votes

Nunjucks {% include %} needs the file extension to properly include the file. While you said you also tried {% include 'header.njk' %}, I wasn't able to reproduce the issue if the file extension (.njk) was provided.

I've created a minimal setup in Glitch to replicate your issue, but it seems to work for me. Take a look and see if anything is different in your project.