A personal blog website built with Node.js and Express, self-hosted on a Raspberry Pi 5 behind a Cloudflare Tunnel. Posts, comments, and visits are stored in flat JSON files therefore no database required.
Originally based on the Net Ninja YouTube series "How to build a blog with Node.js, Express and MongoDB", then heavily modified: MongoDB swapped for JSON file storage, full redesign, admin panel, image uploads, visitor logging, Markdown rendering, and a /now page...
- Runtime: Node.js
- Framework: Express 5
- Templating: EJS + express-ejs-layouts
- Storage: JSON files (no database)
- Markdown: marked v4
- File uploads: multer
- Sessions: express-session
- Process manager (Pi): PM2
- Tunnel (Pi): Cloudflare Tunnel
git clone https://github.com/Kushagra000000/Blog-website.git
cd Blog-websitenpm installCopy the example and fill in your details:
cp site.config.example.js site.config.jsEdit site.config.js with your name, tagline, email, and social links.
cp .env.example .envOpen .env and set:
SESSION_SECRET=pick-a-long-random-string
NODE_ENV=development
PORT=3000
SESSION_SECRET is your admin panel password. Choose something strong.
npm start# SSH into Pi
ssh pi@<your-pi-ip>
# Clone repo
git clone https://github.com/Kushagra000000/Blog-website.git
cd Blog-website
# Install dependencies
npm install
# Follow the setup instrucctions...
# Start with PM2
pm2 start app.js --name kushagra-blog
pm2 save
pm2 startup
### Cloudflare Tunnel (as on my initial setup)
The tunnel connects your Pi to your domain without exposing your home IP
This is required if you don\'t have access to your router settings.
```bash
# Check tunnel is running
cloudflared tunnel list
# to start
cloudflared tunnel run <your-tunnel-name>
# To run it as a service (restart on reboot of device)
sudo cloudflared service install
sudo systemctl start cloudflaredMIT — use freely, attribution appreciated but not required.