Search code examples
gatsbynetlify-cms

Sourcing from netlify cms


I followed the tutorial on Gatsby's site. I have the 'hello world' https://admiring-bose-8807f8.netlify.com/ site running. I've created a post but stuck getting it to show. I'm using the gatsby-source-filesystem plugin. My gatsby-config.js file is as follows:

module.exports = {
  /* Your site config here */
  plugins: [
    `gatsby-plugin-netlify-cms`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `blog`,
        path: `${__dirname}/blog`
      },
    },
    `gatsby-transformer-remark`,
    ]
}

and my config.yml is

backend:
  name: github
  repo: jamesgrubb/Gatsbycms

media_folder: static/assets
public_folder: assets

collections:
  - name: blog
    label: Blog
    folder: blog
    create: true
    fields:
      - { name: path, label: Path }
      - { name: date, label: Date, widget: date }
      - { name: title, label: Title }
      - { name: body, label: Body, widget: markdown }

When I get in to the admin and click to create a new post I have the following fileds

  • Path
  • Date
  • Title
  • Body

I have input the following strings:

  • Path: /first-blog/
  • Date: (pre-filled)
  • Title: Title
  • Body: Lorem ipsum

How should I be formatting my URL? I've tried: https://admiring-bose-8807f8.netlify.com/blog/first-blog/Title

no joy?

Any ideas


Solution

  • I check out your repo on github & I think you've missed the part where you have to query for the markdown files and then render them in gatsby-node.js. Checkout this official tutorial or inspect the official blog starter source.