A Gatsby blog engine like no other

Meet the Gatsby blog engine that integrates with your website using a straightforward API. Smooth, simple, and tasty content integration — that’s Butter.

Posted on November 28, 2023

Intuitive admin interface

So easy to use. So easy to customize. You’re going to love the blog you build with ButterCMS.

Handy integration with Gatsby.js

Our Gatsby blog engine has a simple content API and drop-in SDKs that make the magic happen in minutes, not hours.

A truly zero-maintenance solution

With ButterCMS, you’ll never worry about security upgrades, hosting, or performance again.

You've got better things to do than build another blog

Drop our Gatsby blog engine into your app, and get back to more interesting problems.

ButterCMS is an API-based blog engine that integrates seamlessly with new and existing Gatsby apps. It's great for SEO, and provides a clean and modern user interface that your marketing team will love. You can deploy ButterCMS in minutes using our Gatsby API client.

That leaves plenty of time for you and your marketing team to do what you do best: create killer apps with killer content.

Play video

See how Butter’s API enables you to launch a flexible blog with amazing SEO using your existing tech stack.

G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award G2 crowd review award

Best blog engine on the market

headshot of Hampton Catl

After shopping the market, it was clear that ButterCMS was the perfect choice. It allows our developers to build powerful components and makes it easy for our marketing team to drive a better customer experience. Hampton Catlin Creator of Sass and Haml

Deploy our Gatsby starter in 30 seconds

Or follow the below commands to clone a copy of the repo from github, install dependencies, set your free Butter token, and run your local server.

$ git clone https://github.com/ButterCMS/gatsbyjs-starter-buttercms.git
$ cd gatsbyjs-starter-buttercms
$ npm install
$ echo 'BUTTER_CMS_API_KEY=your_free_api_token_here' >> .env
$ npm run develop

Built to make content marketing easy

ButterCMS is the best Gatsby blog engine for a simple reason: Gatsby developers can build solutions that marketing people love. Our API allows your content gurus to quickly spin up high-converting blog templates, sidebars, related content features, and more, all using simple drag-and-drop functionality.

  • Use main domain (improves SEO)
  • Friendly admin interface
  • Upload images, video, and other media
  • Edit URL slugs and meta tags
  • Tags and categories
  • Author profiles
  • RSS/Atom feeds
  • Search
  • Webhooks
  • And more...

The simplest Gatsby blog engine you'll find

Our simple setup saves you time and money. Take us for a spin to see for yourself!

headshot of LUKE GARDNER

It's the epitome of plug-and-play simplicity for content creators. It does exactly what I need it to. LUKE GARDNER, CONTENT SPECIALIST, PRINTAVO

Fast integration with any Gatsby app

Our mission was to make it easy to integrate Butter with your existing Gatsby app in minutes. It’s so simple! To demonstrate, here’s a mini tutorial to give you a feel for the process of adding Butter to your Gatsby.js app.

Of course, you can also use our Pages and Collections to do advanced content modeling. For a full integration guide, check out our Official Guide for the ButterCMS Gatsby API client.

Play video

See how easily you can integrate the ButterCMS Pages API with your Gatsby.js app.

Seamless Gatsby components

Empower your marketing team to create a customized blog engine that aligns perfectly with your Gatsby components.

Components are the essential building blocks of any Gatsby app, and ButterCMS handles them with ease.

Our drag and drop interface makes it simple to structure your content to match existing Gatsby components and to create new reusable components whenever you need them.

The best Gatsby blog engine for SEO

ButterCMS gives you absolute control over on-page SEO ranking factors. Key SEO variables are built into our default post template, giving your marketing team direct access to configure all of these settings, and more.

  • Page title
  • Post tags and categories
  • META description
  • URL slug
  • Featured image / Open Graph image
  • Image ALT tags
  • Link anchor text

ButterCMS saves you development time

Most customers get our Gatsby blog engine up and running in less than an hour. Try it yourself!

headshot of DILLON BURNS

Simple as can be, with powerful features and great customer support. DILLON BURNS, FRONT END DEVELOPER, KEYME

How to integrate ButterCMS into your Gatsby application

Integrating the Butter blog engine into your Gatsby app is dead simple. Here's a mini tutorial to get a feel for setting up your blog home and blog post pages.

For a full integration guide, check out our Official Gatsby Guide.

In src/pages/blog.js

import React from 'react'
import { Link, graphql } from 'gatsby'
import Layout from '../components/Layout'
import SEO from '../components/seo'

class BlogIndex extends React.Component {
  render() {
    const { data } = this.props
    const siteTitle = data.site.siteMetadata.title
    const posts = data.allButterPost.edges

    return (
      <Layout location={this.props.location} title={siteTitle}>
        <SEO title="Blog Home" />

        <div>
          {posts.map(({ node }) => {
            const title = node.seo_title || node.slug
            return (
              <div
                key={node.slug}>
                <h3>
                  <Link to={`/blog/${node.slug}`}>
                    {title}
                  </Link>
                </h3>
                <small>{node.date}</small>
                <p>{node.summary}</p>
              </div>
            )
          })}
        </div>
      </Layout>
    )
  }
}

export default BlogIndex

export const pageQuery = graphql`
  query {
    site {
      siteMetadata {
        title
      }
    }
    allButterPost {
      edges {
        node {
          id
          seo_title
          meta_description
          slug
          categories {
            name
            slug
          }
          author {
            first_name
            last_name
            email
            slug
            bio
            title
            linkedin_url
            facebook_url
            instagram_url
            pinterest_url
            twitter_handle
            profile_image
          }
          body
        }
      }
    }
  }
`

Creating a blog template

Now we've listed our blog posts in src/pages/blog.js, using Gatsby createpages API we'll generate blog post pages using a template:

In src/pages/template/blog-post.js:

import React from 'react'
import { Link, graphql } from 'gatsby'

import Bio from '../components/Bio'
import Layout from '../components/Layout'
import SEO from '../components/seo'

class BlogPostTemplate extends React.Component {
  render() {
    const post = this.props.data.allButterPost.edges[0].node
    const siteTitle = this.props.data.site.siteMetadata.title
    const { previous, next } = this.props.pageContext

    return (
      <Layout location={this.props.location} title={siteTitle}>
        <SEO title={post.seo_title} description={post.description} />
        <div>
          <div>
            <h1>{post.seo_title}</h1> <span>{post.date}</span> •
            {post.categories.map(category => (
              <span>{category.name}</span>
            ))}
            <hr />
            <div
              dangerouslySetInnerHTML={{ __html: post.body }}
            />
            <Bio />
            <ul>
              <li>
                {previous && (
                  <Link to={`/blog/${previous.slug}`} rel="prev">
                    ← {previous.seo_title}
                  </Link>
                )}
              </li>
              <li>
                {next && (
                  <Link to={`/blog/${next.slug}`} rel="next">
                    {next.seo_title} →
                  </Link>
                )}
              </li>
            </ul>
          </div>
        </div>
      </Layout>
    )
  }
}

export default BlogPostTemplate

export const pageQuery = graphql`
  query BlogPostBySlug($slug: String!) {
    site {
      siteMetadata {
        title
        author
      }
    }
    allButterPost(filter: { slug: { eq: $slug } }) {
      edges {
        node {
          id
          body
          seo_title
          date
          categories {
            name
          }
        }
      }
    }
  }
`

Generate Blog Pages

Now we'll use the blog template defined in src/templates/blog-post.js to generate blog pages.

In gatsby-node.js:

const path = require(`path`)

exports.createPages = async ({ graphql, actions }) => {
  const { createPage } = actions

  const blogPost = path.resolve(`./src/templates/blog-post.js`)

  let posts
  try {
    posts = await graphql(`
      {
        allButterPost {
          edges {
            node {
              id
              seo_title
              slug
              categories {
                name
                slug
              }
              author {
                first_name
                last_name
                email
                slug
                profile_image
              }
              body
            }
          }
        }
      }
    `)
  } catch (error) {
    console.log(`Error Running Querying Posts`, error)
  }
    
  posts = posts.data.allButterPost.edges;

  posts.forEach((post, index) => {
    const previous = index === posts.length - 1 ? null : posts[index + 1].node
    const next = index === 0 ? null : posts[index - 1].node

    // Create blog posts pages.
    createPage({
      path: `/blog/${post.node.slug}`,
      component: blogPost,
      context: {
        slug: post.node.slug,
        previous,
        next,
      },
    })
  })
}

Now our app has a working blog that can be updated easily in the ButterCMS dashboard. 

Configure the source plugin

Here you'll specify the config that will be needed to pull down data from butter. Make sure to add your api_token from your dashboard, in this guide we will add CMS capability to Gatsby for blogging, marketing pages, and more. Below is an example gatsby-config.js file that you'll want to configure for your app. We dive into more detail on the config file in the official guide.

// Example gatsby-config.js file
module.exports = {
{
      resolve: `gatsby-source-buttercms`,
      options: {
        authToken: ``,
        // Use the optional contentFields array for ButterCMS Collections. Any
        // Collections you want the app to have access to should have their
        // slugs explicitly included in the keys array, as seen below.         
contentFields: { keys: [`faq_items`, `faq_headline`], // Optional. Set to 1 to enable test mode for viewing draft content. test: 0, }, // Optional. Array of page slugs. pages: [`homepage`], // Optional. Array of page types.
        // Use the optional pageTypes array for ButterCMS PageTypes. Any 
        // Page Types you want the app to have access to should have their
      // slugs explicitly included in the pageTypes array, as seen below.
pageTypes: [`customer_case_study`],
        // Specify locales you want the app to have access to, if you have 
        // locales enabled in your account.
locales: [`en`, `fr`] }, }, }

That's it! The blog posts created in your Butter dashboard will immediately show up in your app.

Get Started for Free

Try Butter free for 14 days

See for yourself what makes Butter the best Gatsby blog engine out there. Click the button below to sign up for your free 14-day trial.