Ignore files from collection (hugo _index.md)
See original GitHub issueI 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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:21
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Ignore .md files in build with particular param set - HUGO
I know that hugo has ignoreFiles variable in configuration that ignores files from rendering and are not included in build, but that's based...
Read more >Hugo exclude file types from page bundle? - Stack Overflow
As per the documentation, you can exclude content files with the ignoreFiles directive. In your specific case, add the following to your config....
Read more >Changelog — ox-hugo - Org to Hugo exporter
Provides another means of setting the Org-hugo base directory. ... Just as ox-md.el supports `#+md:` and ox-html.el supports `#+html:`.
Read more >rstudio/blogdown: docs/02-hugo.Rmd - Rdrr.io
Basically, Hugo generates foo/index.html for foo.md by default instead of ... A Hugo theme\index{Themes} is a collection of template files and optional ...
Read more >Hugo: ignore _index.md in list templates | kevingimbel.de
`` checks if the file name is not _index.md - this will ignore all _index.md files from being rendered with the article-preview.html template....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I really dislike this workaround, because it requires additional frontmatter in every page. It would be better if we could define:
filter: {field: "visible", value: "!false"}
orignore: {field: "visible", value: "false"}
or something similiar, so we only need to edit the hidden pages.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):
Front matter of a file to be excluded or filtered:
Option and fields to use into your collection config:
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.