AI writes most of our code these days, but it still helps to understand what's happening under the hood. Here's how I hand-built a simple blog using the SleekCMS CLI.
Getting started
I created an empty site at app.sleekcms.com, then installed the SleekCMS CLI:
# Mac/Linux
curl -fsSL https://app.sleekcms.com/install.sh | sh
# Windows
irm https://app.sleekcms.com/install.ps1 | iex
I selected my site, "Blog site," which set up a local workspace at ~/SleekCMS/blog-site-xdz1jm.
Defining the blog model
Next, I defined a model for blog posts:
// File: src/models/pages/blog+.model
{
title: text,
image: image,
content: markdown
}
This model gives us a ready-made UI for creating and editing posts.
Adding a blog post
With the model in place, I added my first post:
---
// File: src/content/pages/blog+/my-first-blog.md
title: "My First Blog Post"
image: unsplash:blog post|My First Blog
---
# This is my first blog post
Then I wrote a view template to render each post:
Building the post view
Lets add view for blog posts -
<%# src/views/pages/blog+.ejs %>
<h1><%= item.title %></h1>
<%- img(item.image, '600x400') %>
<div><%- marked(item.content) %></div>
Listing posts on the home page
Finally, the home page needed a list of all posts:
<%# src/views/pages/_index.ejs %>
<h1><%=item.title%></h1>
<ul>
<%
let posts = getPages('/blog', { collection: true }) || [];
posts.forEach((post) => { %>
<li><a href="<%=path(post)%>"><%=post.title%></a></li>
<% }) %>
</ul>
Wrapping up
And that's it - a fully CMS-backed blog with proper forms, live previews, and everything needed to publish to a real domain.
Honestly, you don't even need to write this by hand. Ask an AI assistant to scaffold it for you, and it'll typically produce something well-structured and SEO-ready out of the box.


Top comments (0)