NodeJs
Serve a Mini Website with Express
Now that your server is running, let’s make it serve a small website instead of just plain text.
We will create two pages. A home and an about page. Both will share the same CSS file for styling, and each page will have a link to the other using an <a> tag.
Create a Public Folder
Inside your project folder, create a new folder called public. This is where your web pages and CSS file will go. Your folder structure should now look like this:
My First Server/
│
├─ index.js
├─ package.json
├─ node_modules/
└─ public/
├─ index.html
├─ about.html
└─ styles.cssMembers only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 8 more lessons in NodeJs.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.