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:
collections:
- label: "News (English)"
name: "news_english"
folder: "content/news"
path: "{{year}}/{{month}}/{{slug}}"
preview_path: "news/{{year}}/{{month}}/{{slug}}"
create: true
filter: {field: "language", value: "en"}
fields:
- {label: "Language", name: "language", widget: "select", options: ["en", "es", "ko"]}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Body", name: "body", widget: "markdown"}`