We assume you've worked with @gridsome/source-filesystem
and @gridsome/transformer-remark
before this guide.
Gridsome requires Node.js and recommends Yarn. How to setup
gridsome create my-gridsome-site
to create a new projectcd my-gridsome-site
to open foldergridsome develop
to start local development serverGridsome already provides you a set of plugins to get you started.
yarn add netlify-cms gridsome-plugin-netlify-cms @gridsome/source-filesystem @gridsome/transformer-remark
to install the required dependenciesnpm add netlify-cms gridsome-plugin-netlify-cms @gridsome/source-filesystem @gridsome/transformer-remark
Alright, the plugins are installed, it's now time to setup the right configuration. Open the gridsome.config.js
file and make sure it looks like this:
module.exports = {
siteName: 'Gridsome',
transformers: {
remark: {
externalLinksTarget: '_blank',
externalLinksRel: ['nofollow', 'noopener', 'noreferrer'],
anchorClassName: 'icon icon-link',
plugins: [
// ...global plugins
]
}
},
plugins: [
{
use: '@gridsome/source-filesystem',
options: {
path: 'posts/**/*.md',
typeName: 'Post',
remark: {
plugins: [
// ...local plugins
]
}
}
},
{
use: `gridsome-plugin-netlify-cms`,
options: {
publicPath: `/admin`
}
},
]
}
Please read gridsome-plugin-netlify-cms, transformer-remark for more information about the configurations.
It's time to add the CMS!
admin
directory inside the src
uploads
directory inside the root of your projectindex.html
, index.js
and a config.yml
file to your admin
directoryYour index.html
should look like this:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Netlify CMS</title>
</head>
<body>
<script src="index.js" type="module"></script>
</body>
</html>
Your index.js
should look like this:
import CMS from "netlify-cms"
Your config.yml
for Github should look like this:
backend:
name: github
repo: your_name/repo_name
media_folder: "static/uploads"
public_folder: "/uploads"
collections:
- name: "posts"
label: "Posts"
folder: "posts"
create: true
slug: ""
fields:
- {label: "Title", name: "title", widget: "string"}
- {label: "Excerpt", name: "excerpt", widget: "string"}
- {label: "Publish Date", name: "date", widget: "date"}
- {label: "Body", name: "body", widget: "markdown"}
Your config.yml
for Bitbucket should look like this:
backend:
name: bitbucket
repo: owner-name/repo-name # Path to your Bitbucket repository
# The rest of the configuration...
Before we can start adding posts we'll have to give Netlify access to our Github, this part is crucial, please follow the steps closely. More info can be read here;
Part 1, GitHub:
https://api.netlify.com/auth/done
as authorization
callback URLPart 2, Netlify:
Another way of integration Netlify CMS could be with the Bitbucket OAuth. Please follow the steps closely. At the moment, there is a lack of support for Editorial Workflow when working with Bitbucket Bitbucket Editorial Workflow;
Part 1, Bitbucket:
https://api.netlify.com/auth/done
as authorization
callback URLPart 2, Netlify:
Your basic blog scaffold is done, now you can query data from the GraphQL server just like you're working with the filesystem. For more info read querying data.