Build your own blog with Next.js and Sanity

Written by Knut Melvær

Sometimes you just need a blog. While there are plenty of dedicated blogging platforms, there are good reasons for having your blog content live alongside your other content, be it documentation, products, a portfolio, or whatever else you're building. A blog is also a great first project for learning how to build with structured content.

In this tutorial, we'll build a blog with Sanity as the content backend and Next.js for rendering web pages. You'll learn how to:

We'll also set up AI tooling so your coding assistant can help you along the way.

PortableText [components.type] is missing "callout"

0. Set up your projects and tools

In this project, you'll have two separate apps:

  1. Sanity Studio, where you create and manage your blog content
  2. Next.js frontend, the website that displays your blog

We'll keep them in separate folders. You can embed the Studio directly in a Next.js app, but keeping them separate makes it easier to learn how the pieces connect.

Create the Sanity Studio

Open your terminal and run:

Internal server error