Hello, I’m new to Netlify CMS. I need help configuring the collections to read and write posts in a blog folder structure that resembles {{year}}/{{month}}/{{slug}}.
I have a site built with Hugo that supports three languages. The language code appends to the URL as www.example.com/es/ but the default is English.
The blog entries in Hugo’s file structure exist in the content folder under a folder called news and are organized by additional sub-folders by year and month, e.g., content/news/2020/06/slug-for-article.md. All articles have identical file locations and slugs except the language code is appended before the .md file extension, e.g., slug-for-article.en.md, slug-for-article.es.md.
I was able to setup the CMS but am unsure how to configure collections so that:
The collections show existing articles in the {{year}}/{{month}} folders.
New articles are created in the appropriate {{year}}/{{month}} folders.
Here’s a sample of the collections configuration for an English label:
@cptncrnch Welcome to the Netlify Community. I don’t know the answer to your question, but I changed the topic from netlify-newbie to netlify-cms, as that seemed to fit better.
Thanks, @erez, the {{fields.language}} tag helped create the file extensions with proper locale. I realize now that the files are saving in the correct directory, but it’s the filter setting that isn’t properly showing the files in each collection. If I remove the filter setting line, I’m able to see all of the files in the news folder from every subdirectory. If I keep the filter settings as follows:
filter: {field: "language", value: "en"}
then the collection shows No Entries.
All of my original posts didn’t have the language variable in their frontmatter, so I expected them to not show in the collection. However, when I created a new post within Netlify CMS and edited an existing post to include the language: en line in the frontmatter, they also didn’t show in the appropriate filtered collection.
The frontmatter of the newly created test post looks like this:
language: en
title: Test post
date: 2020-07-01T01:55:14.324Z
(I haven’t looked into the DateTime widget settings yet.)
The frontmatter of my edited existing post looks like this:
language: en
title: “Title of Post”
date: 2020-06-09T06:00:00-07:00
@erez, I have 22 entries. Sorting the entries does force load the entries and I’m able to see the two posts with the language: en line in its frontmatter.