Build a custom UI for your blog
There are two ways to give your blog a design of your own:
- A custom template. You write the HTML and CSS. Superblog still builds, hosts and optimizes the blog.
- Headless. You build your own frontend and fetch your posts from the REST API.
Both are available on the SUPER plan and above.
Start with a custom template unless your blog has to render inside an app you already run. With a template, Superblog keeps adding the SEO tags, schemas, sitemaps and llms.txt to every page. With the headless route, your frontend has to produce all of them itself.
Working examples of both are in the sample repository.
Option 1: a custom template
A custom template replaces Superblog's design with your own markup. You write one HTML file per type of page, and Superblog fills it with your posts, categories, tags and settings.
- Install the Superblog CLI and sign in:
npm i -g @superblog/cli
superblog login
- Start a live session in an empty folder:
mkdir my-template && cd my-template
superblog template dev
It offers to create a starter template, then builds your real blog with it at a live preview address. Save a file and the page reloads. Your live blog does not change.
- Publish when it is ready:
superblog template preview
superblog template deploy
Choose how to style it
The CLI asks one question when it creates the starter:
The choice is saved in template.json, and you can change it later. The sample repository has the starter for each: template-tailwind/ and template-own-css/.
What Superblog keeps doing for you
- The
<head>of every page: SEO tags, canonical URLs, Open Graph tags and fonts. A template cannot change these, so it cannot break them. - JSON-LD schemas, sitemaps, RSS and llms.txt.
- Image optimization, hosting and the CDN.
- A check on every build. A template with an error stops the deploy and names the file and line, so a broken design never goes live.
The full template reference is in every starter, in docs/index.html. To build the template with a coding assistant such as Claude or Codex, point it at docs/LLMS.md. See Build your own template for how a template works with your dashboard settings.
Option 2: headless with the REST API
Fetch your posts from the REST API and render them with any framework.
- Create an API key with Read published content access. It can read your published posts and nothing else, so a leaked key cannot change your blog.
- List your published posts. The API returns up to 200 posts per page:
curl "https://write.superblog.ai/api/v2/sites/yourblog/posts?statusFilter=PUBLISHED&limit=200&page=1" \
-H "Authorization: Bearer YOUR_API_KEY"
- Fetch one post by its
cuidfrom that list. Itscontentfield is HTML, ready to render:
curl https://write.superblog.ai/api/v2/sites/yourblog/posts/POST_CUID \
-H "Authorization: Bearer YOUR_API_KEY"
Replace yourblog with your blog's supername, the first part of its superblog.click address.
The API looks posts up by cuid, not by slug. To build a page for each slug, list the posts first and match the slug to its cuid. The headless-nextjs/ example in the sample repository does this in Next.js, with a static page and SEO tags for every post.
Before you go headless
- Keep the API key on your server. Call the API at build time or from server code, never from the browser. A read published content key cannot change anything, but anyone who has it can still read your content through the API. A full access key can edit and delete everything on your blog, so never use one in a frontend.
- Your frontend owns SEO. Titles, descriptions, canonical URLs, JSON-LD schemas, the sitemap, RSS and llms.txt are added by the blog Superblog hosts. A headless frontend has to generate each of them.
- Avoid duplicate pages. If you also deploy the blog Superblog hosts, the same posts are public at two addresses. Set each post's canonical URL to its page on your frontend, so search engines index yours.
- Edits show up when your frontend fetches them. The API returns your posts as they are in the dashboard, with no Superblog deploy needed. How soon readers see a change depends on how often your frontend rebuilds or re-fetches.
Only need your latest posts?
To show a few recent posts on your homepage or in an app, you do not need either option. Every blog publishes its posts as RSS and JSON, on every plan, with no API key. See Show your posts on another site or app.