Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template Not Found #1431

Open
Nani2777 opened this issue Jan 20, 2023 · 1 comment
Open

Template Not Found #1431

Nani2777 opened this issue Jan 20, 2023 · 1 comment

Comments

@Nani2777
Copy link

Nani2777 commented Jan 20, 2023

I have been trying to run my demo site and was able to run it successfully from the current directory but after configuring the service file in systemd was unable to run it.

`nunjucks.configure("views", {
autoescape: true,
express: app
});

app.set('views', path.join(__dirname, 'views'));
app.set("view engine", "nunjucks");

app.use("/public", express.static(__dirname + "/public"));
app.use("/", express.static(__dirname + "/"));

app.get(["/","/index","/index.html"], (req, res) => {
data.base_file = __dirname + '/views/base_file.njk';
res.render(__dirname + "/views/index.njk", data);
})`

And Directory structure as follows
Screenshot from 2023-01-20 14-28-07

Below is the Error Screenshot
Screenshot from 2023-01-20 14-37-06

Can someone please help

@hrydi
Copy link

hrydi commented Jan 29, 2023

i'am facing the same issue, but now already fixed it.
this is my setup:

const viewpath = path.join(__dirname, './views')
const nnjk = require('nunjucks')
nnjk.configure(viewpath, {
  autoescape: true,
  express: app,
})
app.set('views', viewpath)
app.set('view engine', 'html')

just set your view path equal to express views
hope this would help,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants