Statamic Headless Tied to a Gatsby Blog [Tutorial & Live Demo]
Tags: javascript, webdev, tutorial, php
Published: 2020-12-10 15:49:57

---
title: Statamic Headless Tied to a Gatsby Blog [Tutorial & Live Demo]
published: true
date: 2020-12-10 09:15:54 UTC
tags: javascript, webdev, tutorial, php
canonical_url: https://snipcart.com/blog/statamic-headless-gatsby-blog-tutorial
---

![Statamic Headless Tied to a Gatsby Blog [Tutorial & Live Demo]](https://snipcart.com/media/205516/statamic-headless-gatsby-blog-tutorial.png)

It’s hard to mention any other languages than JavaScript when writing about the Jamstack. 

As with most modern web trends, [JavaScript is *everywhere*](https://snipcart.com/blog/why-javascript-benefits).

However, it would be false to say that this paradigm can’t open its arms to “traditional” programming language like, say, PHP.

Case in point: the Laravel-powered CMS, Statamic. Changes made in its latest version now allow developers to use it as a headless CMS, making it a perfect fit for [Jamstack](https://snipcart.com/blog/jamstack) projects.

And that’s exactly what I’m going to do today. **In this tutorial, I’ll use Statamic headless to manage and feed data to a Gatsby frontend**, resulting in a neat little blog.

Here’s what I’ll cover:

- Installing Statamic as headless
- Creating a new Gatsby project
- Setting up the Statamic GUI
- Adding new collections
- Using Statamic to feed the Gatsby blog
- Handling Statamic’s data
- Creating a blog post layout

I’m no PHP expert, so I’ll certainly learn a thing or two along the way as well. Let’s dive right in!

## What is Statamic?

![statamic-tutorial](https://snipcart.com/media/205517/statamic-tutorial.png)

Statamic (and its latest version, v3) is many things:

- It's a Content Management System (CMS) where data can be pulled via an API endpoint. You *can* use it as [a headless CMS](https://jamstack.org/headless-cms/) (as I’ll do in the tutorial below.)
- It's a Static Site Generator (SSG) that can be deployed to any Content Delivery Network (CDN) known to man. 
- It's a content creation tool, enabling content creators to write posts and store and distribute videos. 
- It's an open-source, PHP-based, Laravel package designed to scale and be used as both a front and backend.

Phew, that was a lot of joy to be throwing Statamic’s way. As a first time user, I found the experience of setting it up and grabbing data rather painless. Of course, I stumbled a few times; we’ll go over those together so that you don't have to do it alone. 

But all in all, I'd have to say that I'm mightily impressed! Also, the site and docs are just super cool to look at. Reading the copy feels like chatting with a mate down at the pub on a Sunday.

With the release of v3, Statamic introduced a formal way of grabbing the data stored and making it headless: the [content API](https://statamic.dev/content-api). In v2, there was the possibility to use an addon called [Fetch](https://statamic.com/addons/aryeh-raber/fetch), which would supply JSON endpoints, but with the introduction of the content API, getting your hands on that lovely data has become a first-class citizen. It's now fully supported with a read-only endpoint. 
  

→ Read the full post [here](https://snipcart.com/blog/statamic-headless-gatsby-blog-tutorial)