I'm encountering an issue with my "index.ejs" file...
The current content of the ejs file:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<!-- THIS SECTION IS FOR <head> TAG THAT WILL BE STORED INSIDE "so_head-tag.ejs" -->
<%- include('/home/username/Desktop/www/website.com/views/partials/so_head-tag.ejs') %>
<body>
<!-- THIS SECTION IS FOR NAVIGATION BAR THAT WILL BE STORED INSIDE "so_header.ejs" -->
<%- include('/home/username/Desktop/www/website.com/views/partials/so_header.ejs') %>
<div class="filler">
</div>
<!-- THIS SECTION IS FOR FOOTER BAR THAT WILL BE STORED INSIDE "so_footer.ejs" -->
<%- include('/home/username/Desktop/www/website.com/views/partials/so_footer.ejs') %>
<!-- THIS SECTION IS FOR JAVASCRIPT FILES THAT WILL BE STORED INSIDE "so_javacript.ejs" -->
<%- include('/home/username/Desktop/www/website.com/views/partials/so_javacript.ejs') %>
</body>
</html>
Although the pages are rendered perfectly in the current setup, I have a challenge with using absolute paths. When transferring files to a new server, I need to manually update the usernames in each path as they might differ between servers. I would prefer to implement a relative path approach.
The current file placements are shown here:
https://i.sstatic.net/8FPeP.png
I am facing difficulties in implementing relative paths as it triggers an error when I try using this in the ejs file:
<%- include(__dirname + '/views/partials/so_footer.ejs') %>
Error message displayed is:
dirname is not defined.
I appreciate any assistance provided in resolving this issue.