Search code examples
htmlnode.jsexpressexpress-generator

How do i use Express Generator to make node skeleton for Html view engine?


How do i make a skeleton for node js using express generator for html view engine? like for example we use

npm install -g express-generator

express -v pug

but cant create skeleton for

express -v html


Solution

  • Not really understanding why you want to use express if you going to serve html but anyway, if you don't want to learn a new syntax/language ejs is the way to go

    express -v ejs

    ejs is pure html but you can insert code into it, but clean html work just fine as well. One thing, if you going to have truly static html you can use the public folder. Files from that folder is presented "as is".

    Some ejs examples are In render file

    res.render('mypage', {title: 'The first page', wellcome: 'Wellcome'});
    

    in view file (mypage.ejs)

    <html><title><%= title %></title></head><body><%= wellcome => to <%= title %></body></html>

    For more information go to https://ejs.co/