Iggs_Grey
Iggs_Grey

Reputation: 91

Mode of Deploying Your Web Page

I'm quite new to node.js, having migrated from php... So in php you can create say a file called headcode.php and you can put tour navbar there and anything else that needs to be at the beginning or in the head of all your pages, then you can go ahead and include it in all pages on your site.

My question is, how do we do this in node.js? I tried fs.readFile but it only showed html with no css And i noticed i can't type node.js in an html file, neither can i type html in a .js file without doing res.write for each line of html which is rather tedious. How can i implement this php ideology of "headcode.php" into node.js?

Upvotes: 0

Views: 12

Answers (1)

Florian sp1rit
Florian sp1rit

Reputation: 585

I reccomend using the express framework (expressjs.com). There are a lot of good and free tutorials on how to use it. And with the use of a Templating Engine like EJS, Handlebars or PUG you can use partitials and even a base Layout (Exception EJS, you need another npm module for this (express-ejs-layouts)

Here are the Docs on howto install the Templateengine of your choice using express. (expressjs.com/en/guide/using-template-engines.html)

Upvotes: 1

Related Questions