DEV Community

Cover image for Launch a custom blog in 5 minutes using SleekCMS
Yusuf B
Yusuf B

Posted on

Launch a custom blog in 5 minutes using SleekCMS

SleekCMS is a headless CMS with a built-in static site builder. Here is how you can launch a custom code blog with a headless CMS interface in minutes.

Firstly, sign up at app.sleekcms.com and create a custom/empty content site.

Create Content Models

Next, let's add two page models:

  1. Home - /
title: text
Enter fullscreen mode Exit fullscreen mode
  1. Blogs - /blog/*
title: text
image: image
content: markdown
Enter fullscreen mode Exit fullscreen mode

Model UI interface
Model view in SleekCMS

Add some content

Next, head to content editing, add a site title, and draft a few blog posts. Use Unsplash integration to find a good image and built-in AI to create a post.

Content Editing in SleekCMS

Using built-in static site builder

SleekCMS comes with a built-in static site builder. You can attach EJS templates to your content models and build a complete static site without needing any server or code repository. We will deploy our site via Netlify using its hosting provider integrations.

Attach code templates to models

The site builder has zero setup Tailwind CSS integration. So we will use that for styling. Also, all templates are executed with all of our content and utility method context that we can directly use to integrate with our markup.

Template for the Home page model

<h1><%= item.title %></h1>
<ul>
  <% findPages("/blog/").forEach(function(page) { %>
    <li>
      <a href="<%= path(page) %>">
          <h4><%= page.title %></h4>
      </a>
    </li>
  <% }); %>
</ul>
Enter fullscreen mode Exit fullscreen mode

Template for the Blog page model

<article>
  <a href="/">Back to home</a>
  <h1><%= item.title %></h1>
  <figure>
    <img src="<%=img(item.image, '800x400')%>" />
  </figure>
  <%- item.content %>
</article>
Enter fullscreen mode Exit fullscreen mode

And, let's add a wrapper layout to both of these:

<main class="min-h-screen bg-gray-50 py-8 flex flex-col relative">
  <div class="mt-8 prose prose-slate mx-auto">
    <%- main %>
  </div>
</main>
Enter fullscreen mode Exit fullscreen mode

Preview and Publish

That is it. You can now preview your blog and publish it via Netlify using the built-in integration. Add your Netlify token, create a site, and publish.

You can preview the result of these steps here - DevTo Demo Blog

Try it out, and share what you create.

Top comments (0)