I have a hugo site in which I have a content called "project".
My config file:
collections:
- name: "project"
editor:
preview: false
label: "Project"
folder: "site/content/project"
create: true
fields:
- {label: "Featured", name: "featured", widget: "boolean", default: false}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Project Date", name: "project_date", widget: "datetime"}
- {label: "Head Image (Recommended 1920x1080)", name: "head_image", widget: "image", required: false}
- {label: "Thumbnail Image (Recommended 360x560)", name: "thumb_image", widget: "image", required: false}
- {label: "Images", name: "images", widget: list, field:
{label: "Image (Recommended 800x500)", name: "image", widget: "image"}}
- {label: "Description", name: "body", widget: "markdown"}
The admin is working fine and I can create/edit my projects. The issue is that the admin also show the _index.md file which is used from hugo for the list page. Also this file has different front-matter (I have a file collection for this to edit from the cms).
The solution you'd like
For hugo site should automatically excludes this file from the collection.
alternatives you've considered
Maybe a better and more generic solution for all SSGs is to have a config option to let us give an array with some files to be ignored
Should be possible, agreed.
maybe this issue #1472 would minimize the needed of this feature
Hi everyone!
Have there been any updates on this issue? I've looked at #1472 but I didn't find any solution or talk related to this. I'm interested in this feature to show only the actual collection content with a Hugo site and not "collection metadata" files.
I'd be happy to help implement this
Hi @GabriFila, the current workaround is to use https://www.netlifycms.org/docs/collection-types#filtered-folder-collections
e.g. have a show field on entries and add a filter entries with that value set to true.
Also related https://github.com/netlify/netlify-cms/issues/1000
Thank you @erezrokah, I'll try that.
Is there an interest to implement this without a workaround but with an actual ignore field, maybe with a regex inside or a glob pattern? Would it create problems?
I'm going to have a look at the suggestion to add a type: exclude/include to filter and also to support entry meta data like filename.
Feels like it shouldn't be much of an effort, but I'll have to verify it.
Using a regex/glob might be a bit tricky to do without a breaking change
Thank you! I have little experience with React, I don't know if I could help but if you need me I'd be happy to do it!
Hi @GabriFila, the current workaround is to use https://www.netlifycms.org/docs/collection-types#filtered-folder-collections
e.g. have ashowfield on entries and add a filter entries with that value set totrue.
Also related #1000
I used this workaround, it's easy and clean. Just do something like this in your collection config and your md files to be ignored or included:
Front matter of a file to be included (I removed some lines from your example for clarity):
featured: true
title: Some title
date: 2020-07-14T22:49:10.427Z
visible: true
---
Front matter of a file to be excluded or filtered:
featured: true
title: A title for an _index.md
date: 2020-07-14T22:49:10.427Z
visible: false
---
Option and fields to use into your collection config:
collections:
- name: "project"
editor:
preview: false
label: "Project"
folder: "site/content/project"
create: true
filter: {field: "visible", value: true}
fields:
- {label: "Featured", name: "featured", widget: "boolean", default: false}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Visible", name: "visible", widget: hidden, default: true}
Pay attention to the filter option, visible label, and the visible fields in the frontmatter of the files. Now all your new files created with the CMS will include the visible label, hiding the files with visible: false for the CMS, and without any interaction with the user.
Thank you for mentioning the hidden widget, I used with the filter but it was still visible to the end user, now it will be much better
Thank you for mentioning the
hiddenwidget, I used with the filter but it was still visible to the end user, now it will be much better
Let us know if you resolved the problem. 驴Did you notice the filter option?
Yes yes I solved my problem, it's still a workaround but is fine for me. If and when there will be another way I'll change it.
Thank you
Most helpful comment
I'm going to have a look at the suggestion to add a
type: exclude/includetofilterand also to support entry meta data like filename.Feels like it shouldn't be much of an effort, but I'll have to verify it.
Using a regex/glob might be a bit tricky to do without a breaking change