Encountering difficulties in running bootstrap on nodejs

As a beginner in node.js and bootstrap, I am eager to create my own personal website, so I found some tutorials to help me get started.

After downloading bootstrap 2.0.2 and unzipping it, I organized the files by placing bootstrap and bootstrap-responsive in the stylesheets folder of my project, and bootstrap.js and jquery.js in the javascripts folder. Following the instructions, I made changes to the index.jade and layout.jade as shown below:

**layout jade:**
$<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head>
  <title><%= title %> - Microblog</title>
  <link rel='stylesheet' href='/stylesheets/bootstrap.css' />
  <style type="text/css">
   body {
    padding-top: 60px;
    padding-bottom: 40px;
   }
  </style>
  <link href="stylesheets/bootstrap-responsive.css" rel="stylesheet">
 </head>
</html>$


    **index.jade
   <div class="hero-unit">
   <h1>Welcome to Microblog</h1>
   <p>Microblog is a microblogging system based on Node.js.</p>
   <p>
   <a class="btn btn-primary btn-large" href="/login">Login</a>
   <a class="btn btn-large" href="/reg">Register Now</a>
   </p>
   </div>
   <div class="row">
   <div class="span4"> 
   <h2>Carbo says</h2>
   <p>The east wind breaks the early plum blossoms. <br>Only one branch blossoms towards warmth; alone, it's seen. <br>Spring comes from above, unseen by men.</p>
   </div>
   <div class="span4">
   <h2>BYVoid says</h2>
   <p>
   Open Chinese Convert (OpenCC) is an open-source Chinese simplification project, dedicated to creating high-quality statistical-based Simplified-Chinese character conversion wordlists. <br>They also provide a function library (libopencc), a command line simplification tool, manual proofreading tools, dictionary generation programs, online conversion services, and a graphical user interface.</p>
   </div>
   <div class="span4">
   <h2>佛振 says</h2>
   <p>The Middle Chinese Rhyme input method engine / Rime Input Method Engine is inspired by the historical Middle Chinese Rhyme, aiming to create a classic input method that gathers the wisdom of phonology. <br>The project website can be found at http://code.google.com/p/rimeime/ <br>While creating application value is important, it is equally essential to uphold the pursuit of good technology. The goal is to write dynamic and easily scalable code, making it a unique open-source input method.</p>
   </div>
   </div>**

Unfortunately, the layout doesn't look as expected. Can someone please point out what is wrong? I am stuck at this basic step and unsure how to proceed. Thank you!

Answer №1

  1. The formatting and structure of your code does not appear to align with the Jade markup language.
  2. It looks like you have not included links to jQuery.js and bootstrap.js in your layout.jade or index.jade files.

An example of what you might expect to see:

!!! 5
html
  head
    title #{meta.title} - #{meta.author}
    link(rel="stylesheet", href="/twitter/bootstrap.css")

    script(type="text/javascript", src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js")    
    script(type="text/javascript", src="/scripts/bootstrap.min.js")
...

Answer №2

Hey there! Your HTML code doesn't seem to be in Jade syntax. You can easily convert it by pasting it here:

Looking for more information on Jade syntax? Check out these docs:

Just starting out with Express? Consider using Hogan as a template, which is more "html like" and is already built in (although you'll need to specify it when initializing a new project).

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

"Tailor your package installations based on the current version of your Node

My current project relies on the websocket package, with version 1.0.31 working for node 10.x but not for node 4.x which works with version 10.0.24 of websocket. Is there a way to specify different package versions based on the node.js version being used? ...

Dim the shading of a portion of the picture

If you have an image that covers an entire element through CSS like this #myDiv {background-image: url("../images/background.jpg "); background-repeat: no-repeat; background-size: cover; background-position: center;} Now, what if you want to add a gray ov ...

What is the process for moving entered data from one text box to another text box when a checkbox is selected?

I need help with a function that reflects data entered in one text box to another text box when a checkbox is ticked. The checkbox is initially checked and the values should change when it is unchecked and then checked again. Currently, the code is only ou ...

Is it possible to send mail without requiring the use of the SMTP port number or host name?

I have the username and password for an email account, but I am missing the SMTP host name and port number. I am currently using Nodemailer. Can I send emails using only the username and password for the email account? Edit: Please don't dismiss my ...

How to disable form submission using ENTER key in jQuery when alerts are present?

My form contains a text input field. To prevent the form from being submitted when ENTER key is pressed, I used this code snippet: jQuery("#inputTags").keydown(function(event) { if (event.keyCode == '13') { event.preventDefault() ...

When sending a request from Vue.js using Axios to PHP, the issue arises that the .value property is

There is a chat box with bb smileys underneath. Clicking on the smileys adds them to the text in the input box. However, when using axios to post, the array is empty. Manually entering the smiley bbcode works fine. <input id="txtName" @keyup.enter="ad ...

Is there a way to align all the content in a Bootstrap card to the center?

Need help centering content in a bootstrap card for my semester project. Can't seem to get it right! If anyone can assist, I would really appreciate it. Also hoping to increase the height of the card if possible. <link rel="stylesheet" href= ...

Creating a dynamic carousel with adjustable images

My image carousel is giving me trouble with responsiveness, specifically the height of the images. While the width looks okay, the height is only half of what I need. Can someone offer some ideas on how to make my image height 100% responsive? I've tr ...

I'm encountering inexplicable duplications of elements on my Wordpress site

Here is an example of my template header: <header> <?php if ( function_exists( 'jetpack_the_site_logo' ) ) jetpack_the_site_logo(); ?> <a class="menu-toggle">menu</div> <?php wp_nav_menu( array('them ...

What is the best way to deliver dynamic content through static files?

For instance, I am looking to customize the user's access to the secondary domain by directing them to the appropriate directory: app.use(express.static(path.join(__dirname, '/public'))); TO: app.use(express.static(path.join(__dirname, &a ...

Is it possible to use mssql queries in Nodejs similar to mysql2?

When I was working with mysql2 in Nodejs, I found using queries to be very straightforward. ('select * from table where A = ? AND B = ?', [val1, val2]) However, now that I am using mssql, I am finding it to be quite inconvenient. const result = ...

Is there a way to display two words side by side in React components?

I previously had the following code: projectName: project.get('name') === 'default' ? 'No Project' : project.get('name') In the render() method, it was written like this: <div className='c-card__projects&ap ...

Incorporating Bootstrap Content: A Guide to Including a PHP File within Another PHP File

I am encountering an issue when trying to import a PHP file containing my navigation bar into another PHP file. Here's the code for the navigation file: <?php echo " <html> <head> <nav class = "navbar navbar-default navbar-fixed-top ...

Configuring Redis deployment for master-slave replication strategy

Currently, I am running two servers where I have deployed web services APIs based on node.js/Express.JS. I am utilizing Redis for caching JSON strings. When it comes to deploying this setup in production, what would be the best option? According to this s ...

How to add items to a Mongoose array

Hey there, I've hit a roadblock with this issue. I need to clear and update my array in mongoose and here's all of my router code: router.get("/update", (req, res, next) => { // Finding the object to be updated const promise ...

The transparency of the navigation menu is perplexing to me. I am unclear as to the reasoning behind it. I desire a

I am currently using a pre-made WordPress theme. Recently, I incorporated particles.js as the background for my website. The issue I am facing now is that my navigation menu is blending into the same color as the background. I have tried defining a separat ...

I wonder where the file from the HTML form download has originated

Recently, I've been experimenting with the developer tools in Chrome to observe the behavior of websites at different moments. It has proven useful in automating certain tasks that I regularly perform. Currently, my focus is on automating the process ...

retrieve an item that lacks a definitive value

Here's an object I have: Obj = { foo: false, bar: true, private: { something: 'else' } } Now, I'm trying to return this object without the private part. Since the private part is used elsewhere and cannot be spliced out, I ...

Can the sliding transition effect used in createMaterialTopTabNavigator be implemented in createMaterialBottomTabNavigator as well?

When using createMaterialTopTabNavigator, the transition from screen to screen involves a sliding effect as you press the tabs. On the other hand, createMaterialBottomTabNavigator uses a fading-in animation for its transitions. Is there a way to combine o ...

What is the basic structure of a JSON-like object?

How can data be effectively stored in a JSON-like structure? I have noticed two different approaches to storing data within a json object, each with its own method for accessing the data (illustrated using examples in Python): Approach 1: obj1 = [ {" ...