Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Ejs include partials files not rendering

I am trying to use ejs in a node js project. I have managed to render the views file(.ejs') and use the .js data in it. and getting the desired webpage including the stylesheet. the problem occurs only while using partial After importing the header.ejs file in customer.ejs I am getting the exact text syntax of the header.ejs on the webpage. <%- include("partials/header") %> In short customer.ejs is locating the header file and importing the it fine. but not rendering it

Output

�� <�head> <�link rel="stylesheet" href="/css/style.css"> <�title>Customer<�/title> <�/head> 
Name: abc

my directories are as follows project\public\css\style.scc project\views\partials\header.ejs> project\views\customer.ejs project\app.js i am using Express my syntax are as follows

app.js

 app.use(express.static('public'));
 app.set('views', './views');
 app.set('view engine', "views");

customer.ejs

<html >
<%- include("partials/header") %> 
<body>
    <h1>
         Name: <%= customer.name %>
    </h1>   
    
 </body>
 </html>

header.ejs

<head>

    <link rel="stylesheet" href="/css/style.css">
    
    <title>Customer</title>
</head>

Things i tried

<%- include partials/header %> <%- include("partials/header") %> <%- include("./partials/header") %> <%- include("partials/header.ejs") %> and several more.. also tried using the express-partial module. also tried it on different browsers. Please let me know if i am doing something wrong or using a decrypted method Any help would be appreciated. Thank you.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I got the answer to my question after surfing google for a significant amount of time. Something went wrong with the Unicode After pasting the following in the root dir the problem was solved. Just after hitting enter, my entire app.js got changed to some Chinese text. but ctrl+z brought my code back.

Get-Content .\app.js -Encoding Unicode | Set-Content -Encoding UTF8 
.\app-fixed.js ; Move-Item -Path .\app-fixed.js -Destination .\app.js - 
Confirm -Force 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!