Skip to main content

Overview

This integration guide shows you how to how to update your existing project to:
  1. install the ButterCMS package
  2. instantiate ButterCMS
  3. create components to fetch and display each of the three ButterCMS content types: Pages, Collections, and Blog Posts.
In order for the snippets to work, you’ll need to setup your dashboard content schemas inside of ButterCMS first.

Starter project

Or, you can jump directly to the starter project below, which will allow you to clone, install, run, and deploy a fully working starter project that’s integrated with content already inside of your ButterCMS account.

Hugo Starter Project

Hit the ground running with a pre-configured Hugo + ButterCMS setup.

Overview

Hugo doesn’t have native CMS integrations, so you’ll use ButterCMS by:
  1. Fetching content at build time using a Node.js script
  2. Saving content as Hugo data files or Markdown
  3. Using Hugo templates to render the content

Installation

Add your API token to .env:

Build configuration

For complete SDK documentation including all available methods and configuration options, see the JavaScript SDK Reference.

Pages

Page template

Collections

Collections are automatically fetched to data/collections.json. Access them in templates:

Dynamic components

Component partial

Component renderer

Using in templates

Store component data in page front matter during generation, then render:

Blog

Webhooks for rebuilds

Set up webhooks to trigger rebuilds when content changes:
  1. Go to SettingsWebhooks in ButterCMS
  2. Add your build hook URL:
    • Netlify: Site Settings → Build & Deploy → Build hooks
    • Vercel: Project Settings → Git → Deploy Hooks
    • Cloudflare Pages: Configure a webhook trigger
  3. Select events: Page Published, Post Published, etc.

SEO

Hugo configuration

Resources

JavaScript SDK

Complete SDK reference

Webhooks

Set up content webhooks

GitHub Repository

View source code

Content API

REST API documentation