Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:40:53+00:00 2026-06-01T11:40:53+00:00

I am currently working with the Express framework for Node.js and I am having

  • 0

I am currently working with the Express framework for Node.js and I am having trouble including stylesheets and javascript files on a per page (route) basis. I am using the default Express setup with a routes/index.js file with the following content:

exports.index = function(req, res){
    res.render('index', { title: 'Index Page Test' })
};
exports.browse = function(req, res){
  res.render('browse', { title: 'Browse Page Test' })
};

The routes above works fine and it loads index.jade and browse.jade into the “body” of layout.jade as expected. However, the assets (CSS and JS files) that the index route requires is not the same as what the browse route requires. Is it possible for me to pass an array to the layout.jade template containing the required assets and simply have it looped?

I attempted to do the above via:

Index.js (Route)

scripts: [
   'javascripts/jquery.js',
   'javascripts/easel.js',
   'javascripts/script.js'
]

Followed by:

Layout.jade

    each js in scripts
        script(src= js)

However, it simply throws an error saying “scripts is not defined.”
I am pretty sure I am not doing this right. Also, just to add, I stumbled upon another similar StackOverflow question here: Node.js with Express: Importing client-side javascript using script tags in Jade views?
But I am not too keen on the method shown there (it requires an additional helper). If possible, I would like to stick to the functions provided by the template engine itself.

Thanks.

EDIT: If it helps, I am trying to achieve something similar to this: http://kerkness.ca/kowiki/doku.php?id=template-site:create_the_template

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:40:54+00:00Added an answer on June 1, 2026 at 11:40 am

    Try to pass the scripts array to the views like this:

    res.render('index', { title: 'Index Page Test', scripts: scripts})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm currently building a small music quiz running node.js 0.4.12 and the express framework
I am currently working on a project using the Express framework. I have a
i m currently working on visual c++ 2008 express edition.. in my project i
I'm currently working on a small web application using Visual Studio 2008 Express. I'm
I'm currently working on a Silverlight application connected to a SQL Server 2008 Express
Currently working on a flex AIR project based on PureMVC framework. There was a
Hi Im currently working with .sdf database (Server Compact Version 4.0) and sql express.
I'm working on my first node.js / express / mongoose app and I'm facing
Currently working in the deployment of an OFBiz based ERP, we've come to the
Currently working on a VBScript to automate some of the dirty PST ingestion work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.