Why we moved habuild.in from hard-coded pages to an admin-driven CMS
Every sentence on our site used to need an engineer, a pull request and a deploy. Here is why we rebuilt habuild.in on Payload CMS and Next.js, and how we kept it fast.
For most of its life, habuild.in was a website that only engineers could change. The pages were built in Next.js, and almost everything on them, from the hero headline on a program page to the order of the FAQs, lived in code. Our long-form articles lived somewhere else entirely: a separate WordPress install, reverse-proxied under /habitology.
That setup got us a long way. It also meant that every sentence on the site had an engineer, a pull request and a deploy standing between it and our members.
This post explains why we replaced it with a single, admin-driven application built on Payload CMS and Next.js, what we were careful not to lose along the way, and what changed for the people who write for and build the site.
Where we started
The site had two halves that grew up separately.
- •The main site was a Next.js application. Pages were fast and looked the way we wanted, but their content was part of the source code. Changing a price card, a testimonial or a line of copy meant editing a component, opening a pull request, waiting for review and shipping a build.
- •The blog, Habitology, ran on WordPress at a different origin and was stitched into habuild.in by a reverse proxy. It had its own theme, its own header and footer, and its own plugin stack for SEO.
Each half made sense on its own. Together, they created a set of problems that got worse as the team and the content grew.
What was hurting
Content changes were engineering work. The marketing and content teams knew exactly what they wanted to say, but they could not say it without us. Small copy edits queued behind feature work, and engineers spent real time on changes that were not engineering problems.
Two stacks, two experiences. A reader moving from a program page into an article crossed into a different design, a different navigation and a noticeably different speed. Fixing something site-wide meant fixing it twice, in two very different systems.
The blog was hard to keep fast and consistent. The WordPress pages were not on the same caching architecture as the rest of the site, their design had drifted from the main brand, and their SEO output depended on what a plugin chose to emit.
Hindi was an afterthought. We serve a large Hindi-speaking audience, but neither half of the site had translation built into the content model. Every localised page was a special case.
Content had no structure. A WordPress post is mostly one large body of HTML. That is fine for an essay and poor for anything we wanted to reuse: a specialist profile, a program's batch timings, a testimonial that appears on five pages.
What we needed instead
Before choosing a tool, we wrote down what the replacement had to do.
- 1.Editors publish without a deploy. Content changes should go from the admin to the live site in minutes, with no engineer involved.
- 2.Structured content. Programs, specialists, articles and testimonials should be typed records that pages assemble, not paragraphs of HTML.
- 3.A safe editorial workflow. Drafts, autosave, previews of unpublished changes, version history and scheduled publishing.
- 4.English and Hindi in one model. A Hindi page should be the same document in another locale, not a copy that drifts.
- 5.No loss of speed. Moving content into a database must not put that database on the path of every page view.
- 6.One application. One codebase, one design system, one deploy, one place to look when something breaks.
- 7.Engineers stay in their tools. Schema in TypeScript, changes reviewed in pull requests, everything in git.
Why Payload
Payload CMS ticked those boxes in a way that suited a small engineering team.
It runs inside our Next.js app. Since version 3, Payload installs into a Next.js App Router project. The admin panel lives at /admin, the REST and GraphQL APIs live under /api, and the public site is rendered by the same application. There is no separate CMS service to host, scale, secure and keep in sync with the frontend.
The schema is code. Collections, fields, validation, access rules and hooks are TypeScript files in the repository. They are reviewed like any other change, and Payload generates TypeScript types from them, so a renamed field breaks the build instead of a page.
It uses Postgres, with real migrations. Content lives in a relational database we already know how to run. Every schema change is a generated migration file that is committed, reviewed and applied deliberately. Nothing alters the production schema implicitly.
The editorial features are in the open-source core. Drafts, autosave, versions, scheduled publishing, localisation and live preview are part of Payload itself, not a paid tier.
It is extensible where we need it. Lifecycle hooks let us run code on every save, the Local API lets server code read content without an HTTP round trip, and the Lexical rich-text editor accepts our own custom blocks.
The trade-off is that Payload is a framework rather than a finished product. We own the content model, the rendering and the operational rules. For us, that was the point.
Modelling the site as content
The first real work was deciding what the site is made of. Today the admin holds a little over twenty collections and around ten globals, including:
- •Articles and categories for Habitology, our long-form health and wellness writing.
- •Programs, free programs and their landing pages, assembled from reusable blocks such as batch timings, benefits, trainers, FAQs and how-to-register steps.
- •Specialists and specialist types, rendered as profile pages and listings.
- •Programmatic pages and buckets, for landing pages we generate at scale from structured data.
- •Testimonials, member stories and press mentions, written once and placed wherever they are needed.
- •Globals for site-wide content such as the header, footer, home page and trust banners.
Most pages are built from blocks: typed, reusable sections an editor can add, reorder and fill in. Engineers design and build a block once; editors decide where it goes and what it says.
Localisation is part of the model. Every document holds English and Hindi values for its localised fields, and a missing Hindi value falls back to English field by field. A Hindi page is the same document served in the hi locale, so the two can never drift structurally.
Editors get a real workflow. Changes autosave as drafts. Editors preview an unpublished draft on the real page before anything goes live, schedule a publish for later, and roll back to an earlier version if they need to.
A CMS that does not slow the site down
The biggest risk in moving content into a database is that every page view starts touching it. A CMS-backed page that queries Postgres on each request is easy to build, and it fails the first time traffic spikes.
We decided early that reader traffic must never reach the database, and designed every route around that rule. A request passes through three layers:
Reader→ CloudFront short TTL (5 minutes); serves the large majority of traffic→ Next.js ISR cache kept until the content is edited; no database query→ Postgres reached only on publish, the daily refresh, builds and admin use
Three decisions make this work.
Every page is static or incrementally regenerated. Pages are prerendered at build time and kept in the Next.js cache. Database-backed pages list their paths up front and carry a daily safety-net refresh:
// A database-backed page: prerendered, then cached until its content changes.export const revalidate = 86400export async function generateStaticParams() {const articles = await listPublishedArticles()return articles.map((article) => ({categorySlug: article.category.slug,articleSlug: article.slug,}))}
Reading cookies or request headers in a page would silently make it dynamic and put the database back on the hot path, so our lint rules block those calls on every public page.
Publishing refreshes exactly the pages it affects. Each collection that renders on the site has an afterChange hook that tells Next.js which paths to regenerate: the document's own page, the listings that show it, and its old URL if the slug changed.
// Simplified: on publish, regenerate the article and the listings that show it.export const revalidateArticle: CollectionAfterChangeHook = ({ doc, context }) => {if (context.disableRevalidate) return docif (doc._status === 'published') {revalidatePath(`/habitology/${doc.category.slug}/${doc.slug}`)revalidatePath(`/habitology/${doc.category.slug}`)revalidatePath('/habitology')}return doc}
Autosave makes this subtler than it looks. With drafts on, the "previous document" a hook receives is the latest autosaved draft, not the live page, so detecting a slug change or an unpublish means checking the published version history. It is an easy trap to fall into, so every hook follows one reference implementation.
The CDN refreshes itself instead of being purged. We do not call the CloudFront invalidation API on edits. A five-minute time-to-live means CloudFront refetches each page at most every five minutes, and Next.js answers that refetch from its cache unless the page was actually edited. An edit is live within five minutes, invalidation quotas and costs never come into it, and the database stays quiet.
The result is a content site whose database is mostly idle. Its load tracks how much our editors work, not how many people read.
Moving the content over
A new platform is only useful once the content is on it, and our articles had years of history in WordPress.
We wrote an importer that reads WordPress posts and converts their HTML into Payload's rich-text format. The rule we held to was simple: never drop content silently. Wherever the WordPress markup had no equivalent in our editor, such as embedded videos, callouts or custom layouts, we built a custom block for it instead of flattening it to text or discarding it.
URLs needed the same care. We kept the existing route structure, so /habitology/{category}/{article} still points where it always did, and redirects cover the cases that did change. A small build step keeps a list of every top-level route the app owns, so a new program or landing-page slug can never shadow a real page.
Guardrails for a growing team
A CMS that many people edit, built by a team that keeps growing, needs rules that machines enforce rather than ones people remember. Every commit and every pull request runs the same set of checks, locally through git hooks and again in CI:
- •Formatting, linting, type checking and unit tests must pass, with core utility code held at 100% test coverage.
- •Generated files stay current. If a schema change alters the generated TypeScript types or the admin's component map, the check fails until they are regenerated and committed.
- •Schema changes ship with migrations. The check regenerates the migration snapshot offline and fails if a field changed without a migration.
- •Pages stay static. The lint rules described above catch any page that would start querying the database per request.
- •Files stay small. No source file may exceed 300 lines, which keeps modules focused and reviewable.
Because the hooks and CI run one shared script, a green local run and a green pull request mean the same thing.
Shipping it
Every change moves through the same path: a feature branch, then development, then staging, then production. Each environment has its own pipeline, its own database and its own secrets, which live in a secrets manager and never in the repository.
Builds produce one Docker image per commit, tagged with the commit hash, so every deploy is immutable and traceable to the exact code it runs. Database migrations are applied deliberately and separately from deploys, after a check of what is pending. The application reports traces, metrics and structured logs through OpenTelemetry, so a slow page or a failed publish can be followed from the request down to the query.
What changed
For editors, the site is now theirs to run. They create and update pages, preview changes before anyone else can see them, schedule launches, and publish in English and Hindi, without filing a ticket.
For engineers, the work has moved from editing copy to building capabilities: new blocks, new page types, better performance. One application means one design system, one deploy and one place to debug.
For readers, the experience is consistent. Articles, programs and landing pages share the same design, the same navigation and the same caching, so the whole site is fast, not just parts of it.
This blog is a good example. It is a new section of the site, with its own content types for teams, categories, authors and posts, and it went from idea to production on the same foundations without a new service, a new database or a new deploy pipeline.
What we learnt
- •Decide the caching rules on day one. Keeping every page static was far easier as a rule from the first commit than it would have been as a clean-up later.
- •Treat the schema like code. Generated migrations, reviewed in pull requests and applied on purpose, have kept environments predictable.
- •Never drop content in a migration. A custom block for an awkward piece of markup costs an afternoon. Losing content costs reader trust.
- •Know your scaling limits. Our cache refresh currently assumes a single application container. Before we run more than one, we will add a shared cache so an edit reaches every instance. Writing that limit down early means it is a plan, not an incident.
We will write more about individual pieces of this system, including the caching design, the import pipeline and the editorial workflow, in future posts.