Blog

This page will give you everything you need to create your own blog posts and put them on your website.

The authentication flow in this boilerplate is powered by Contentful. It is a popular headless CMS with a free plan that allows you to create and manage your content.

Step 1: create your Contentful account

In order to start, you need to create a Contentful account. You can do that here.

Step 2: create your content types

After you have created an account, you need to create a "content model" which is a blueprint for your content. You can create a content type for your blog posts and add fields like title, excerpt, slug, body, image, author, tags, etc.

In our example, the content model looks like this:

  • - title: text
  • - excerpt: text
  • - slug: text
  • - body: rich text
  • - image: media
  • - author: reference
  • - category: reference

Step 3: get the API keys

After you have created a project, you need to get the API keys and fill in the `.env` file in the root of the project.

terminal

Step 4: create your first blog post

Create an example blog post in your Contentful account. Fill in the fields with some example data and publish the post.

You can fetch the blog post by slug using the `getBlogPostBySlug` function from the `routes/blog/contentful.ts` file.

Take a look at the `/routes/blog/[slug]` route to see how the blog posts are fetched and displayed on the website.