Butter offers client libraries for Ruby, JavaScript, Python, C#, PHP, and Go. If we don't have a client for your language or platform, you can integrate directly with our API. You just need to be able to speak HTTP and JSON – see our API reference.

To get started, run this request in your command line:

curl -X GET 'https://api.buttercms.com/v2/posts/?page=1&page_size=10&auth_token=your_api_token'

This request fetches your blog posts. Your account comes with one example post which you'll see in the response.

Next, run:

curl -X GET -H "Authorization: Token your_api_token" \
  'https://api.buttercms.com/v2/content/?keys=homepage_headline'

This request fetches homepage headline content. You can setup your own custom content fields to manage any content kind of content you need.

ButterCMS lets you manage content using our dashboard and integrate it into your front-end of choice with our API. You can use ButterCMS for new projects as well as add it to existing codebases.

ButterCMS comes with a blogging interface and APIs for blog posts, categories, authors, and XML feeds. For other use cases you can setup custom content fields based on your needs.

For example, if you wanted to enable a non-technical person to edit some copy on your homepage, you might create two custom content fields called "Homepage Headline" and "Homepage Main Paragraph". The non-technical person would be able to edit the values of the fields and the JSON API output would look something like this:

{
  "homepage_headline": "OMG I can edit this!",
  "homepage_paragraph": "I love ButterCMS"
}

Custom content fields can be used for more complex cases like creating dynamic pages and managing knowledgebases, which we will cover in this guide.

Table of Contents

Introduction

Learn how to quickly build a blog with Butter.

If you need help after reading this, contact us via email, livechat, or book a time with to pair with one of our developers.

Display posts

The Butter API offers endpoints for fetching lists of posts as well as individual posts. See our API reference for additional options such as filtering by category or author.

To fetch a list of posts, use the /posts endpoint:

curl -X GET 'https://api.buttercms.com/v2/posts/?page=1&page_size=10&auth_token=your_api_token'

The response includes some metadata for pagination:

{
  "meta": {
    "count": 1,
    "next_page": null,
    "previous_page": null
  },
  "data": [
    {
      // Post object
    }
  ]
}

To fetch an individual post, include the slug in the URL. For example, here's what the request would look like for a post with the slug my-post.

curl -X GET 'https://api.buttercms.com/v2/posts/my-post?auth_token=your_api_token'

Categories, Tags, and Authors

Use Butter's APIs for categories, tags, and authors to feature and filter content on your blog.

See our API reference for more information about these objects:

RSS, Atom, and Sitemap

Butter generates RSS, Atom, and sitemap XML markup. To use these on your blog, return the generated XML from the Butter API with the proper content type headers.

Here's what an example request looks like for getting your blog's RSS feed:

curl -X GET 'https://api.buttercms.com/v2/feeds/rss?auth_token=b60a008584313ed21803780bc9208557b3b49fbb'

And the response:

{
  "data": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n \n  <url><loc>http://www.example.com/blog/this-is-a-blog-post</loc></url>\n \n</urlset>"
}

See our API reference for more information about fetching RSS, Atom, and sitemap XML.

Comments

Butter doesn't provide an API for comments due to the excellent existing options that integrate easily. Two popular servies we recommend are:

Both products are free, include moderation capabilities, and give your audience a familiar commenting experience. They can also provide some additional distribution for your content since users in their networks can see when people comment on your posts. For a minimalist alternative to Disqus, check out RemarkBox or for an open-source option, Isso.

CSS

Butter integrates into your front-end so you have complete control over the design of your blog. Use the following CSS as boilerplate for post content styling.

.post-container {
  h1, h2, h3, h4, h5 {
    font-weight: 600;
    margin-bottom: 1em;
    margin-top: 1.5em;
  }

  ul, ol {
    margin-bottom: 1.25em;

    li {
      margin-bottom: 0.25em;
    }
  }

  p {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-size: 1.25em;
    line-height: 1.58;
    margin-bottom: 1.25em;
    font-weight: 400;
    letter-spacing: -.003em;
  }

  /* Responsive default image width */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Responsive floating */
  @media only screen and (min-width: 720px)  {
    .butter-float-left {
      float: left;
      margin: 0px 10px 10px 0px;
    }

    .butter-float-right {
      float: right;
      margin: 0px 0px 10px 10px;
    }
  }

  /* Image caption */
  figcaption {
    font-style: italic;
    text-align: center;
    color: #ccc;
  }

  p code {
    padding: 2px 4px;
    font-size: 90%;
    color: #c7254e;
    background-color: #f9f2f4;
    border-radius: 4px;
    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
  }

  pre {
    display: block;
    padding: 1em;
    margin: 0 0 2em;
    font-size: 1em;
    line-height: 1.4;
    word-break: break-all;
    word-wrap: break-word;
    color: #333333;
    background-color: #f5f5f5;
    font-family: Menlo, Monaco,Consolas, "Courier New", monospace;
  }
}

Migration

To import content from another platform like WordPress or Medium, send us an email.

Table of Contents

Introduction

Learn how to make content on a static page editable using Butter.

Making your content dynamic with Butter is a two-step process:

  1. Setup custom content fields in Butter
  2. Integrate the fields into your application

If you need help after reading this, contact us via email, livechat, or book a time with to pair with one of our developers.

Setup content fields

Let's suppose we want to add a CMS to a static FAQ page with a title and a list of questions with answers. Here's the HTML for the static page:

<h1>FAQ</h1>

<ul>
  <li>
    <h4>When was this company started?</h4>
    <p>2014</p>
  </li>
  <li>
    <h4>What forms of payment do you accept?</h4>
    <p>Credit cards and checks.</p>
  </li>
</ul>

Making your content dynamic with Butter is a two-step process:

  1. Setup custom content fields in Butter
  2. Integrate the fields into your application

To setup custom content fields, first sign in to the Butter dashboard.

Create a new workspace or click on an existing one. Workspaces let you organize content fields in a friendly way for content editors and have no effect on development or the API. For example, a real-estate website might have a workspace called "Properties" and another called "About Page".

Once you're in a workspace click the button to create a new content field. Choose the "Object" type and name the field "FAQ Headline":

After saving, add another field but this time choose the "Collection" type and name the field FAQ Items:

On the next screen setup two properties for items in the collection:

Now go back to your workspace and update your heading and FAQ items.

Integrate your app

To display this dynamic content in our app, we fetch the fields with an API call and then use them in our template.

Here's what API request would look like:

curl -X GET -H "Authorization: Token b60a008584313ed21803780bc9208557b3b49fbb" \
  'https://api.buttercms.com/v2/content/?keys=faq_headline,faq_items'

And the response:

{
  "data": {
    "faq_headline": "ButterCMS",
    "faq_items": [
      {
        question: "why is the world round?",
        answer: "who knows"
      }
    ]
  }
}

And here's what your template might look like:

<h1><%= content.faq_headline %></h1>

<ul>
  <% content.faq_items.forEach(function(item) { %>
    <li>
      <h4><%= item.question %></h4>
      <p><%= item.answer %></p>
    </li>
  <% }); %>
</ul>

That's it! The values entered in the Butter dashboard will immediately update the content in our app.

If you need help after reading this, contact us via email, livechat, or book a time with to pair with one of our developers.

Table of Contents

Introduction

Learn how to create dynamic pages using Butter.

Creating dynamic pages with Butter is a two-step process:

1) Setup custom content fields in Butter
2) Integrate the fields into your application

If you need help after reading this, contact us via email, livechat, or book a time with to pair with one of our developers.

Setup content fields

Let's suppose we want to be able to create pages for retail-chain locations using ButterCMS and we're starting out with a basic static HTML template for a single location:

<h1>Widget Store - Chicago</h1>
<img src="/images/chicago.jpg">
<p>Our Chicago location is located at 566 Wacker Drive.</p>

Enabling new pages to be created with Butter is a two-step process:

  1. Setup custom content fields in Butter
  2. Integrate the fields into your application

To setup custom content fields, first sign in to the Butter dashboard.

Create a new workspace or click on an existing one. Workspaces let you organize content fields in a friendly way for content editors and have no effect on development or the API. For example, a real-estate website might have a workspace called "Properties" and another called "About Page".

Once you're in a workspace click the button to create a new content field. Choose the "Collection" type and name the field "Location Pages":

On the next screen, we’ll setup the properties for each page in the collection.

Now go back to the work space and create a location:

Integrating your app

To display this these pages in our app, we fetch the fields with an API call and then use them in our template.

Here's what the request would look like. Notice that we filter our pages by slug:

curl -X GET -H "Authorization: Token b60a008584313ed21803780bc9208557b3b49fbb" \
  'https://api.buttercms.com/v2/content/?keys=location_pages[slug=chicago]'

Here's what the response looks like. locations is still a collection but contains only one item:

{
  "data": {
    "locations": [
      {
        name: "Chicago",
        feature_image: "",
        description: ""
      }
    ]
  }
}

And here's what your template might look like:

<h1>Widget Store - <%= location.name %></h1>
<img src="<%= location.feature_image %>">
<p><%= location.description %></p>

That's it! If you browse to /locations/chicago, you'll see the content we just entered into Butter.

If you need help after reading this, contact us via email, livechat, or book a time with to pair with one of our developers.

Get started now

Sign up with Google Sign up with Github
or