Whenever I try to access pages from the Menu, I keep getting a frustrating "Page not Found" error message due to the Handlebars rendering

I am currently working on a Menu website using nodeJS, and I prefer not to have all my html.handlebars in one file. I am facing an issue where my rendering is giving me a page not found error. What could be causing this?

Let me share my project structure with you:

| public/
  |-- image/
  |-- javascripts
  |-- stylesheets
    |--Nav.css
    |-- reg.css
    |-- ReviewPr.css

| route
    |-- index.js
|views
  |-- mainlayout
    |--main.hbs  
  |--reg.hbs
  |--ReviewPr.hbs  

  |-app.js

Below are the key sections of my code starting from the route index:

  1. route/index.js : Why isn't my dynamic property 'style' working as expected?
 var express = require('express');
    var router = express.Router();

    /* GET home page. */
    router.get('/', function(req, res, next) {
      res.render('reg', { 
        title: 'Registration',
        style:'reg.css',
        style:'Nav.css'
       });
    });
    // The remaining routes...
    module.exports = router;
  1. views/main.hbs
   <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
    <title>{{title}}</title>
    <link rel="stylesheet"  href="/stylesheets/{{style}}">

    </head>
    <body>

    {{{ body }}}

    </body>
    </html>
  1. reg.hbs (first page: providing link to hbs file)

The content of reg.hbs...

4). views/ReviewPr.hbs : Second page of the website

The content of ReviewPr.hbs...

  1. Finally: app.js

The configuration in app.js...

  1. Here's a screenshot of the application where none of my CSS seems to be working:

https://i.sstatic.net/RZrB6.png

https://i.sstatic.net/GXVhv.png

Answer №1

Make a modification to the URL located in "views/ReviewPr.hbs".

Prior to the change:

<a href="ReviewPr.hbs">Review Priority</a>

New URL:

<a href="/Review Priority">Review Priority</a>

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

Can anyone guide me on locating the current CSS of my shiny app?

I am completely new to CSS so I may be asking the wrong question, but does using navbarPage mean I am incorporating CSS into my web app? I tried adding my own CSS to change some text and background colors... <STYLE TYPE='text/css'> /* ...

Modifying characteristics of a duplicated object will affect every object

After loading an OBJ file, I created a clone of it in an array. However, when I attempt to change the vertex color of one clone, all the clones are affected. How can I create independent clones with unique attributes? var oload = new OBJLoader(); oload.loa ...

JavaScript snap.js button

I'm looking to implement a Toggle button with snap.js from the following source: https://github.com/jakiestfu/Snap.js. The usage instructions on the website are quite concise and I'm struggling to grasp them. Below is the code I've put toget ...

Steps for configuring Angular CLI in a custom directory

As a beginner in the world of Angular and Angular-CLI, I've come across the documentation that mentions the need to install $ npm install -g @angular/cli with the -g (global) flag. Following this, the default path for Angular CLI installation is usual ...

What's the best way to display the spinner while making an axios request?

When I put the spinner on a component did mount method with a setTimeOut method inside, it shows. However, I want the spinner to display only when there is no content on the page. After the axios request finishes loading, the page content should be shown i ...

What is the best way to eliminate the gap between inline-block elements?

I'm trying to make two inline-block divs with width: 50% each fit on one line. <div class="inline">Left one</div> <div class="inline">Right one</div> I know a practical solution, but I also want my code to look nice. <div ...

npm stalls during the postinstall / unlock process

My Linux server, which runs virtual machines using KVM, is based on Debian with kernel 2.6.32-32(-pve). Whenever I try to run npm install, it gets stuck while installing modules about 75% of the time. I tried running it in debug mode and noticed that it a ...

Is it necessary to use the "new" keyword when utilizing JS closure to create objects?

My response to a question about closures on SO included the following code sample: function Constructor() { var privateProperty = 'private'; var privateMethod = function(){ alert('called from public method'); }; ...

Javascript-generated HTML is malfunctioning as sliders are failing to slide

Currently learning Javascript and jQuery as I work on a one-page site using fullPage.js with data fetched from WordPress via JSON. The end goal is to convert this single-page site into a mobile app using cordova. Challenges: Utilizing the right/left slid ...

Having trouble loading CSS in Firefox?

After creating a basic responsive website, I encountered an issue where Mozilla was not loading the CSS properly when the site was hosted on my server. Interestingly, the CSS loaded fine on Chrome and IE when viewed from my computer. Here is a snippet of ...

Assigning controller variables within an ajax request

I'm new to AngularJS and I have a question about controller attributes. I've created an attribute called 'anuncio', which contains an array of objects as shown below: var anuncioModule = angular.module('anuncioModule',[]); a ...

When attempting to retrieve the value of my select element, I encounter difficulty due to a hidden field that only becomes visible when a certain option is selected

I have a dropdown menu with different options, including one labeled "other". When the user selects "other", a hidden text field appears for them to enter a custom value. This functionality works correctly. However, if the user selects any other option and ...

Efficiently displaying dynamic content instantly with jquery and ajax

I am looking to update the information displayed within a block that is generated by <?php print "R";print_r($convert->toCurrency('ZAR', 1));print " / $";print_r($convert->toCurrency('USD', 1)); ?> <div class="col-md-3 ...

Trigger bootstrap dropdown when input is clicked

One of the challenges I'm facing is getting a Bootstrap 4 dropdown to open when a user tabs to it for ADA accessibility. Currently, clicking on the input triggers the dropdown to show, but I need it to work with tabbing as well. Using a focus event a ...

When using HLS with Media Source Extensions on mobile devices, the <video> element with the muted and autoplay attributes may freeze on the first frame

I recently added a background video to our website using mux.com. The video is set to autoplay with HLS, but Chrome requires Media Source Extensions for playback. To ensure the HTML5 video auto plays, I included the necessary mute parameters as well. How ...

Performing XMLHttpRequests and ajax requests inside a foreach loop

I am facing a issue with echoing the decoded array using var_dump. Each time I click the button, a unique xmlhttprequest and ajax call should get executed for every row. However, in reality, the ajax doesn't work as expected. Upon examining the source ...

Organize data efficiently in ng-grid using an external button for seamless layout clarity

I am working with a ng-grid that displays data grouped by category. Here is the setup: $scope.gridOptions = { columnDefs: [ {field: 'cat', displayName: 'Category'}, {field: 'name', displayName: 'Name'}, ...

Building a table with the appendChild() method

I'm a beginner in the world of programming and I've been given a task to create a table of objects. I managed to do it using a certain method, but now I'd like to try creating it using the appendChild method. function addObject() { var ...

What is the best way to retrieve the current directory of the executed javascript file?

My javascript file is located in a folder at this path: /httpdocs/wp-content/themes/themeName/users/js I have some PHP files in another directory within the same theme, where I need to send Ajax Requests: /httpdocs/wp-content/themes/themeName/users Is ...

Guide to dynamically incorporating items from an array into the filter operation

How can I dynamically insert items from an array into the filter on the wizard.html page, so that when the templateUrl in the route is called, it can be rendered on the wizard.html page? Controller angular.module('tareasApp') .controller(&apo ...