Building this site with CodeIgniter 4
This site started as a few static pages on top of a ready-made HTML theme. Today it is a small CodeIgniter 4 application in four languages, with its own CMS for pages, posts and projects.
When I first wrote this post, everything lived in PHP files and publishing meant a deploy. That was fine for a handful of pages, but every new post or translation went through Git. So the content moved to the database, and I built a small admin panel to edit it.
One layout, many pages
Every page still extends the same layout view, which holds the sidebar, the footer and the meta tags. A page only fills its content section. The CSS and JavaScript are built with Vite, Sass and Bootstrap 5, so the browser gets small, cached files.
Four languages
The site is in English, Spanish, Catalan and Romanian, each with its own translated URLs. The interface texts live in language files, and the content is translated in the CMS. A page without a translation is hidden in that language: it is never shown in English instead.
A small CMS
- Pages, blog posts and projects are stored in MySQL, with one translation per language.
- Login, users and roles use CodeIgniter Shield: admins manage everything, editors write posts.
- Posts are written in a rich text editor (TinyMCE), and the HTML is cleaned on save so only the theme's markup gets through.
- Images are cropped to the theme's sizes on upload.
- When a slug changes, the old URL redirects to the new one.
The contact form
- Every message is validated and saved to the database first, with the visitor's language, so I can reply in it.
- Only then is it emailed to me, so a mail server problem never loses a message.
- A hidden honeypot field and CSRF protection keep most spam away.
SEO and the small things
Every page has its own title and description, hreflang links between the languages, a sitemap and structured data. A test suite covers the routes, the translations and the CMS, and a deploy script puts the site in maintenance mode while it updates.
Closing thoughts
I still think not every website needs a big CMS. Building a small one on a light framework gave me exactly the features I use, nothing more, and a site that stays fast and easy to maintain.