NetlifyCMS (& Eleventy) - Issues Creating Blog (Not showing)

I’ve an Eleventy site on Netlify, with source files held in src and publishing to dist. I decided to try NetlifyCMS, and add a blog. So I added a /blog folder under src and pointed the config layout to the post template.

Deployed ok, but I couldn’t get the blog to show, and I’ve many questions - wondering if anyone can provide a clue as to what should be going on.

My config.yml adds a blog collection. But where do I point the path to the folder where the documents are stored? If I point it to a /blog folder, then it writes that to my github repo in a /blog folder outside my src folder. Is this blog folder being written to my dist folder in Netlify?

I assume it can’t write to my src/blog folder, because my understanding is that Netlify isn’t processing anything after the initial build. But then for ongoing local development, do I now have to do a git pull from origin master to my local repo each time, so that I retain those blog posts? Having to do that each time I tweak my local repo would kinda give me the pips.

And how does one create the blog collection? Is it formed within the config.yml, and thus no longer relies on either a ‘blog’ tag, or an addCollection statement in the eleventy.js file? And how would I get those blog posts to appear on my includes/collection template?

I’ve added /blog to my normal navigation, but pointing to Custom Application Development Software for Business - Salesforce.com shows no collection, and there’s nothing on the individual blog page at Custom Application Development Software for Business - Salesforce.com.

Apologies for all the questions. Just couldn’t find the answers. Yet I notice in the various tutorials that their owners seem to have got it working fine and don’t mention those issues. And there’s no platform page for Eleventy. So I’ve got pretty stuck.

Thanks in advance if anyone has any advice on any of those issues!

My config.yml file:

backend:
  name: git-gateway
  branch: prod

media_folder: "src/images/uploads" # Placed in src?
public_folder: "/images/uploads"

collections:
  - name: "blog" # Used in routes, e.g., /admin/collections/blog
    label: "Blog" # Used in the UI
    folder: "/blog" # The path to the folder where the documents are stored
    create: true # Allow users to create new documents in this collection
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
    fields: # The fields for each document, usually in front matter
      - {label: "Layout", name: "layout", widget: "hidden", default: "post", required: false}
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Subtitle", name: "subtitle", widget: "string"}
      - {label: "Extract", name: "extract", widget: "string", required: false}
      - {label: "Summary", name: "summary", widget: "string", required: false}
      - {label: "Publish Date", name: "date", widget: "datetime"}
      - {label: "Featured Image", name: "thumbnail", widget: "image", required: false}
      - {label: "Rating (scale of 1-5)", name: "rating", widget: "number", required: false}
      - {label: "Body", name: "body", widget: "markdown"}

You can. Netlify CMS writes directly to your GitHub repo, so the files in that folder will be available on build, just like any other files in src.

Have a look at this repo for examples:

1 Like

Thanks Tom, that pointer actually helped me a lot :ok_hand:

For other readers in the same boat, I deployed Dan’s site that Tom linked to, started looking through it, and realized its probably beyond my current comprehension (eg. some React shizzle). Will have to work up to understanding it in coming days/weeks.

Looked around and found Andy Bell’s Hyalia is similarly a NetlifyCMS starter, but seems simpler, plus I’m more familiar with his work. Tried it (repo link below), and sure enough, it works as I thought it should. That is:

  1. Uploaded images go into the /src/images folder in my github repo.
  2. New blog posts similarly get saved into the /src/posts folder
  3. New blog posts appear on the collection page, and navigation seems fine
  4. After changes are made, NetlifyCMS seems to whir a bit, my github repo’s source files are updated, and then the changes are published just fine. So I guess it is rebuilding each time.

I spose going forward I need to do a github pull before tweaks, but that’s a small price to pay for the CMS simplicity.

Many thanks again for the help Tom, appreciate your time! :slightly_smiling_face:

Hyalia repo:

1 Like