Adding a Draft Feature to Blog Posts

Learn how to create draft versions of blog posts in Gatsby and keep them hidden from the public.

Introduction to drafts

Often, we tend to have unfinished versions of blog posts on our site. It makes no sense to display draft post versions to our users. Or we may even have some posts that are finished, but we want to keep them from being viewed. This can easily be done.

Creating a draft post

We create one more blog post folder in the /src/posts directory as we did in the previous lessons for the other blog posts. We will name this new post folder Draft-Post and create an index.md file in it. In this index.md file, let’s paste the following content:

Get hands-on with 1200+ tech skills courses.