Building a personal blog from scratch with JavaScript, Node.js, and Express.
I’ve always written reflections and teaching notes, but I wanted a space to publish them online in a format that was mine—not just Medium or WordPress. That meant building a blog engine myself.
Instead of using a pre-made CMS, I built the blog with Node.js and Express, wiring up routes, EJS templates, and Sequelize for database management. It was my first time going full-stack with JavaScript.
Along the way I learned how to manage authentication, CRUD operations for posts, and category filtering. I also added Markdown support for writing posts faster and cleaner.
Express made it straightforward to handle dynamic blog routes:
app.get("/", async (req, res) => {
const posts = await Post.findAll({
where: { status: "published" },
include: Category,
order: [["createdAt", "DESC"]],
});
res.render("index", {
title: "Hey Kniaz",
layout: false,
recentPost: posts[0],
posts: posts.slice(1),
user: req.session.userName || null,
activeCategory: null,
});
});
app.get('/post/:id', async (req, res) => {
const post = await Post.findByPk(req.params.id);
res.render('post', { post });
});