The header.ejs file is unable to render the image

As I work on my website, I had the brilliant idea of using a JavaScript HTTP header (via express) to avoid having to recreate a header and footer on every single file. And guess what? I successfully implemented it! But now I'm facing an issue with inserting a logo (jpeg) into the header and I can't figure out what's wrong...

Here is the code in my header.ejs file:

<!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale">

            <title>Document</title>

            <link  rel="stylesheet" href="css/Header.css">
        </head>
        <body>
            <div id="Header">
                <div id="upper-Header">
                    <img src="../public/img/upper-header.jpg"/>
                </div>
                <div id="lower-Header">
                
                </div>
            </div>
        </body>
    </html>

And here is my app.js file:

const express = require('express');
const app = express();
const port = 3000;


app.use(express.static("./src/public"));
app.use("/css/", express.static(__dirname  + "public/css/"));
app.use("/img/", express.static(__dirname  + "public/img/"));
app.use("/js/", express.static(__dirname  + "public/js/"));


app.set("views", "./src/views");
app.set("view engine", "ejs")

app.get("", (req, res) => {
    res.render("Header", { text: "This is ejs"});
})


app.listen(port, () => {
    console.log(`Listening for port: ${port}`);
});


node_modules
src
   public
       css
         Header.css
         Footer.css
      img
         upper-header.jpg
      js
         Footer.js
         Header.js
  views
     Header.ejs
     Footer.ejs
app.js
package-lock.json
package.json

Answer №1

The image is named upper-Header.jpg, but in your ejs file it is listed as upper-header.jpg. Please make sure to correct the name before proceeding.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhance the speed of my Tumblr page by using JavaScript for personalized styling tweaks

-- Hey there! Dear Reader, if navigating Tumblr isn't your cup of tea, let me know and I'll provide more detailed instructions! I recently ran into some glitches on my Tumblr page while using the default theme 'Optica'. Whenever I tri ...

Exploring PHP cURL with the power of jQuery

function php_download($Url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm"); curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); curl_setopt($ch, CURLOPT_H ...

Angular not rendering d3 uniquely when using *ngFor

I am currently working on integrating angular-d3-donut into my web application. Each should have its own SVG(donut). However, when I use *ngFor to generate multiple s with one SVG(donut) each, only one is being created and multiple SVG(donuts) are nested ...

What are the steps for linking a React Native application to a MongoDB Database hosted remotely?

I have experience creating MERN web apps with separate client and server folders, deploying the entire package on Heroku. Now, I am starting my first React Native project using Expo. I have heard that I should be able to use the same stack, but I am strugg ...

Utilizing nodejs, express, and less-middleware to compile multiple unique LESS stylesheets

Can nodejs and express be used to compile multiple different LESS styles into corresponding CSS styles using less-middleware, as shown below? var less = require('less-middleware'); app.use(less({ src: '/less', dest: '/css ...

What is the best method for submitting form data using AJAX?

I am currently facing an issue with submitting a form that I have created using HTML, JS, PHP, and AJAX. Despite my best efforts, the form does not submit as expected. I suspect that the problem lies within my insert function, but I cannot pinpoint exact ...

What is the best way to define a variable in EJS?

I need to populate my database array results on the frontend using EJS. The code snippet I'm using is as follows: var tags = ["<%tags%>"] <% for(var i=0; i<tags.length; i++) { %> <a href='<%= tags[i] %&g ...

Converting AngularJS scope objects into plain JavaScript arrays: a comprehensive guide

What is the best way to convert an AngularJS scope object into a simple JS array? I have a function that checks if any checkbox is checked and adds the corresponding value to an object. Now, I am trying to transfer the object values to an array and alert ...

Oops! An issue has occurred: Angular template is unable to read the property 'description' as it is undefined

This is my amazing service providing up-to-date information at your fingertips! fetchCurrentAffairs() : Observable<NewsData[]> { return this.httpClient.get<NewsData[]>(`${this.url}/latest`); } Introducing the brilliant component to brin ...

Dynamic element validation in JavaScript

Is there a way to validate text inputs that are generated dynamically? I currently have a "add more" link that adds new text inputs, and a link to remove them. Each input has its own unique ID. In addition, validation should require at least two text box ...

How to target the following element with CSS that has a specified class name

Would it be possible to achieve this using CSS alone, or would I need to resort to jQuery? This is how my code currently looks: <tr>...</tr> <tr>...</tr> <tr>...</tr> <tr class="some-class">...</tr> // My g ...

Can an array be transformed into an object using a function?

I am looking to convert a string into an object in JavaScript. var api_response = { key: "settings.options.height", val: 500 }; keys = api_response.key.split('.'); var settings = { options: { height: 0 } }; I am unsure how to update t ...

Experimenting with mocha and Nightmare.js, utilizing traditional syntax and without the use of ES6 features

Here is a real-world example that I am using: How to Use Nightmare.js without ES6 Syntax and Yield However, when I include it in a Mocha test, it times out. Here's the code snippet: describe('Google', function() { it('should perform ...

Error in Angular2: The provided parameters do not match any of the available function signatures

I have implemented logic in the code snippet below to dynamically adjust rows and columns based on my specific business requirements. However, when I include this code in my Angular2 TypeScript file, I encounter an error stating that the supplied paramet ...

Which alternative function can I use instead of onchange without having to modify the slider beforehand in order for it to function properly?

Check out my website: alainbruno.nl/form.html to see the "Race" form and the "Age" slider. I've noticed that the minimum and maximum values of the Age slider only update correctly when you first use the slider before selecting a different race. Any id ...

Creating a table from a PHP associative array

I've been attempting to organize an associative array in ascending order and then display it in an HTML table, but I've hit a roadblock with an error. I tried searching for solutions here on SO and followed the advice provided in some threads: P ...

a dilemma involving syntax and database connectivity issues within a node.js environment

Here is the code I am using for connecting to my database in Node.js: var express = require('express') var mongoose = require('mongoose') var cors = require('cors') var morgan = require('morgan') require('dot ...

Can the button run a Python script with the help of jQuery?

I'm currently working on setting up a website using a RaspberryPi. I've managed to integrate JustGage for reading temperatures and other sensors in real-time. Now, I want to add a button that when pressed will execute a Python script. Here' ...

Tips on solving the Navigation bar burger problem with HTML and CSS

## I am having trouble making my navigation bar responsive using HTML and CSS as the navigation burger does not appear in mobile view ## To take a look at my code on jsfiddle, click here: [jsfiddle] (https://jsfiddle.net/abhishekpakhare/nxcdso7k/1/ ...

res.redirect() not working after first form submission

I have encountered a strange issue that seems to only occur with specific users. When these users attempt to log in using ActiveDirectory on Google Chrome, the first login attempt does not trigger the redirect properly. However, if they try again after wai ...