<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bootstrap &#8211; Digitaldocblog</title>
	<atom:link href="https://digitaldocblog.com/tag/bootstrap/feed/" rel="self" type="application/rss+xml" />
	<link>https://digitaldocblog.com</link>
	<description>Various digital documentation</description>
	<lastBuildDate>Fri, 02 May 2025 09:03:27 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://digitaldocblog.com/wp-content/uploads/2022/08/cropped-website-icon-star-500-x-452-transparent-32x32.png</url>
	<title>Bootstrap &#8211; Digitaldocblog</title>
	<link>https://digitaldocblog.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Bootstrap Website running as nodejs app</title>
		<link>https://digitaldocblog.com/webdesign/sample-bootstrap-website-running-as-nodes-app/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 22 Mar 2025 07:16:20 +0000</pubDate>
				<category><![CDATA[Web-Development]]></category>
		<category><![CDATA[Webdesign]]></category>
		<category><![CDATA[Bootstrap]]></category>
		<category><![CDATA[Express.js]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Node.js]]></category>
		<guid isPermaLink="false">https://digitaldocblog.com/?p=223</guid>

					<description><![CDATA[First I design the HTML site. The website is a simple Bootstrap-based site. This HTML part has the following tree structure. The index.html contain the HTML and include a navbar,&#8230;]]></description>
										<content:encoded><![CDATA[
<p>First I design the HTML site. The website is a simple Bootstrap-based site. This <strong>HTML part</strong> has the following tree structure.</p>




<pre class="wp-block-code"><code>.
├── images
│&nbsp;&nbsp; ├── 2022-05-28-1-Paterlini-Umbau-80s-Ansicht.jpeg
│&nbsp;&nbsp; ├── 2022-05-28-2-Paterlini-Umbau-80s-Ansicht.jpeg
│&nbsp;&nbsp; ├── 2022-05-28-3-Paterlini-Umbau-80s-Ansicht.jpeg
│&nbsp;&nbsp; ├── 2022-05-28-4-Paterlini-Umbau-80s-Ansicht.jpeg
│&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-1.jpeg
│&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-2.jpeg
│&nbsp;&nbsp; └── 2022-07-09-Gianni-Motta-3.jpeg
└── index.html

</code></pre>



<p>The <em>index.html</em> contain the HTML and include a navbar, a hero section, and a footer. The <em>index.html</em> looks like the following.</p>




<pre class="wp-block-code"><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    &lt;title&gt;Funtrails - Nodejs Demo&lt;/title&gt;
    &lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;!-- Navbar --&gt;
    &lt;nav class="navbar navbar-expand-lg navbar-dark bg-dark"&gt;
        &lt;div class="container"&gt;
            &lt;a class="navbar-brand" href="#"&gt;Funtrails - Demo&lt;/a&gt;
            &lt;button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"&gt;
                &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
            &lt;/button&gt;
            &lt;div class="collapse navbar-collapse" id="navbarNav"&gt;
                &lt;ul class="navbar-nav ms-auto"&gt;
                    &lt;li class="nav-item"&gt;&lt;a class="nav-link" href="#paterlini"&gt;Paterlini&lt;/a&gt;&lt;/li&gt;
                    &lt;li class="nav-item"&gt;&lt;a class="nav-link" href="#motta"&gt;Gianni Motta&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/nav&gt;
    
    &lt;!-- Hero Section --&gt;
    &lt;header class="bg-primary text-white text-center py-5"&gt;
        &lt;div class="container"&gt;
            &lt;h1&gt;Funtrails&lt;/h1&gt;
            &lt;p class="lead"&gt;History of Bikes and Components&lt;/p&gt;
        &lt;/div&gt;
    &lt;/header&gt;
    
    &lt;!-- Patrlini Bike Section --&gt;
    &lt;section id="paterlini" class="py-5"&gt;
        &lt;div class="container"&gt;
            &lt;h2 class="text-center"&gt;Paterlini&lt;/h2&gt;
            &lt;p class="text-center"&gt;Paterlini Road Steel Bike from 1982&lt;/p&gt;
            &lt;div id="paterliniCarousel" class="carousel slide" data-bs-ride="carousel"&gt;
                &lt;div class="carousel-inner"&gt;
                    &lt;div class="carousel-item active"&gt;
                        &lt;img src="images/2022-05-28-1-Paterlini-Umbau-80s-Ansicht.jpeg" class="d-block w-100" alt="Mountain Bike 1"&gt;
                    &lt;/div&gt;
                    &lt;div class="carousel-item"&gt;
                        &lt;img src="images/2022-05-28-4-Paterlini-Umbau-80s-Ansicht.jpeg" class="d-block w-100" alt="Mountain Bike 2"&gt;
                    &lt;/div&gt;
                    &lt;div class="carousel-item"&gt;
                        &lt;img src="images/2022-05-28-3-Paterlini-Umbau-80s-Ansicht.jpeg" class="d-block w-100" alt="Mountain Bike 3"&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;button class="carousel-control-prev" type="button" data-bs-target="#paterliniCarousel" data-bs-slide="prev"&gt;
                    &lt;span class="carousel-control-prev-icon" aria-hidden="true"&gt;&lt;/span&gt;
                &lt;/button&gt;
                &lt;button class="carousel-control-next" type="button" data-bs-target="#paterliniCarousel" data-bs-slide="next"&gt;
                    &lt;span class="carousel-control-next-icon" aria-hidden="true"&gt;&lt;/span&gt;
                &lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/section&gt;
    
    &lt;!-- Gianni Motta Bike Section --&gt;
    &lt;section id="motta" class="py-5"&gt;
        &lt;div class="container"&gt;
            &lt;h2 class="text-center"&gt;Gianni Motta Personal 2001R&lt;/h2&gt;
            &lt;p class="text-center"&gt;Gianni Motta Road Steel Bike from 1989&lt;/p&gt;
            &lt;div id="mottaCarousel" class="carousel slide" data-bs-ride="carousel"&gt;
                &lt;div class="carousel-inner"&gt;
                    &lt;div class="carousel-item active"&gt;
                        &lt;img src="images/2022-07-09-Gianni-Motta-1.jpeg" class="d-block w-100" alt="Road Bike 1"&gt;
                    &lt;/div&gt;
                    &lt;div class="carousel-item"&gt;
                        &lt;img src="images/2022-07-09-Gianni-Motta-2.jpeg" class="d-block w-100" alt="Road Bike 2"&gt;
                    &lt;/div&gt;
                    &lt;div class="carousel-item"&gt;
                        &lt;img src="images/2022-07-09-Gianni-Motta-3.jpeg" class="d-block w-100" alt="Road Bike 3"&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;button class="carousel-control-prev" type="button" data-bs-target="#mottaCarousel" data-bs-slide="prev"&gt;
                    &lt;span class="carousel-control-prev-icon" aria-hidden="true"&gt;&lt;/span&gt;
                &lt;/button&gt;
                &lt;button class="carousel-control-next" type="button" data-bs-target="#mottaCarousel" data-bs-slide="next"&gt;
                    &lt;span class="carousel-control-next-icon" aria-hidden="true"&gt;&lt;/span&gt;
                &lt;/button&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/section&gt;
    
    &lt;!-- Footer --&gt;
    &lt;footer class="bg-dark text-white text-center py-3"&gt;
        &lt;p&gt;&amp;copy; 2025 Funtrails. All rights reserved.&lt;/p&gt;
    &lt;/footer&gt;
    
    &lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>



<p>This website is a one-page bicycle showcase with two sections: one for my Paterlini bike and one for my Gianni Motta bike, each containing a gallery and text. The image galleries in the Bike sections are Bootstrap carousels that allow users to slide through images.</p>




<p>Then I create a new file structure for my node app. Within the <strong>funtrails</strong> directory I create a <strong>views</strong> directory. This is the location where my HTML part will be located. Then I create a <em>package.json</em> file just under <em>funtrails</em>.  I copy the <strong>images</strong> folder and the <em>index.html</em> file from the <em>HTML part</em> above into the <em>views</em> folder of my new structure. The new structure looks like this. </p>




<pre class="wp-block-code"><code>funtrails
├── package.json
└── views
    ├── images
    │&nbsp;&nbsp; ├── 2022-05-28-1-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-2-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-3-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-4-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-1.jpeg
    │&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-2.jpeg
    │&nbsp;&nbsp; └── 2022-07-09-Gianni-Motta-3.jpeg
    └── index.html
</code></pre>



<p>The <em>package.json</em> file has the following code.</p>




<pre class="wp-block-code"><code>{
  "name": "funrails-demo",
  "version": "1.0.0",
  "description": "nodejs funtrails website demo",
  "author": "Patrick Rottlaender &lt;p.rottlaendere@icloud.com&gt;",
  "license": "MIT",
  "main": "app.js",
  "keywords": [
    "nodejs",
    "bootstrap",
    "express"
  ],
  "dependencies": {
    "express": "^4.16.4"
  }
}
</code></pre>



<p>For my node app I use  <strong>express</strong> framework in version 4.16.4 or above. The code of my app will be in the main file <em>app.js</em>. Then I run <em>npm install</em> to install all dependencies. </p>




<pre class="wp-block-code"><code>npm install
</code></pre>



<p>This create a new folder for my node modules and a package-lock.json file. </p>




<pre class="wp-block-code"><code>funtrails
├── node_modules
├── package.json
├── package-lock.json
└── views
    ├── images
    │&nbsp;&nbsp; ├── 2022-05-28-1-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-2-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-3-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-4-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-1.jpeg
    │&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-2.jpeg
    │&nbsp;&nbsp; └── 2022-07-09-Gianni-Motta-3.jpeg
    └── index.html
</code></pre>



<p>I create the main <em>app.js</em> file with the following code.</p>




<pre class="wp-block-code"><code>//Load the express framework
const express = require('express');

//create express app
const app = express();

//create Router instance
const router = express.Router();

//path for static content 
const path = __dirname + '/views/';

//set port 
const port = process.env.PORT || 8080;

//create Middleware
router.use(function (req,res,next) {
    console.log('/' + req.method);
    next();
  });

//create the route handlet for get
  router.get('/', function(req,res){
    res.sendFile(path + 'index.html');
  });

//app will use the static path and the router 
app.use(express.static(path));
app.use('/', router);

//app listens on localhost port 8080
app.listen(port, function () {
  console.log('nodejs funtrails demo app listening on port 8080!')
})                        
</code></pre>



<p>Let&#8217;s go through this Node.js code line by line.</p>




<ul class="wp-block-list">
	<li>require(&#8218;express&#8216;) loads the Express module. This allows us to use express functionalities in our application.</li>
	<li>Calls the express() function to create an Express application. The app object will be used to define routes, middleware, and configure the server.</li>
	<li>Creates a new router instance using express.Router(). The router allows grouping route handlers separately from the main app.</li>
	<li>dirname refers to the directory of the current JavaScript file. Concatenating &#8218;/views/&#8216; results in a full path to the views directory. This will be used to serve static HTML files and images.</li>
	<li>process.env.PORT checks if a port number is set in the environment variables. If not set, it defaults to 8080. This allows the application to use a dynamic port in cloud environments while using 8080 locally.</li>
	<li>This middleware logs the HTTP request method (e.g., GET, POST). req.method returns the request type. next() passes control to the next middleware or route handler. Example logs when requests are made: /GET, /POST</li>
	<li>Defines a route handler for GET / (the home page). Uses res.sendFile(path + &#8218;index.html&#8216;) to send index.html from the views directory.</li>
	<li>express.static(path): Serves static files (CSS, JS, images) from the views directory.</li>
	<li>app.use(&#8218;/&#8216;, router): Registers the router for handling requests.</li>
	<li>Starts the server on the specified port. Logs a message indicating that the server is running.<br></li>
</ul>



<p>The final file structure is as follows.</p>




<pre class="wp-block-code"><code>funtrails
├── app.js
├── node_modules
├── package.json
├── package-lock.json
└── views
    ├── images
    │&nbsp;&nbsp; ├── 2022-05-28-1-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-2-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-3-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-05-28-4-Paterlini-Umbau-80s-Ansicht.jpeg
    │&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-1.jpeg
    │&nbsp;&nbsp; ├── 2022-07-09-Gianni-Motta-2.jpeg
    │&nbsp;&nbsp; └── 2022-07-09-Gianni-Motta-3.jpeg
    └── index.html
</code></pre>



<p>Run the app with node app.js.</p>




<pre class="wp-block-code"><code>node app.js
</code></pre>



]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
