Overview
This integration guide shows you how to how to update your existing project to:- install the ButterCMS package
- instantiate ButterCMS
- create components to fetch and display each of the three ButterCMS content types: Pages, Collections, and Blog Posts.
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:- Fetching content at build time using a Node.js script
- Saving content as Hugo data files or Markdown
- Using Hugo templates to render the content
Installation
- npm
- yarn
- pnpm
.env:
Build configuration
For complete SDK documentation including all available methods and configuration options, see the JavaScript SDK Reference.
Pages
- Fetch Script
- Generate Script
Page template
Collections
Collections are automatically fetched todata/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
- Generate Blog Posts
- Blog List Template
- Blog Post Template
Webhooks for rebuilds
Set up webhooks to trigger rebuilds when content changes:- Go to Settings → Webhooks in ButterCMS
- Add your build hook URL:
- Netlify: Site Settings → Build & Deploy → Build hooks
- Vercel: Project Settings → Git → Deploy Hooks
- Cloudflare Pages: Configure a webhook trigger
- 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