Enhancement: Allow frontmatter.json to be split in multiple files
See original GitHub issueWhen describing complex content types, frontmatter.json quickly become a long and unreadable file. I just finished creating a content type describing Hugo various front-matter fields, and my frontmatter.json has 211 lines of content, and this is just with one complex content type and some frontmatter settings.
Hugo allows to split is configuration file in multiple files stored in config
folder, and named according to the config section they store.
An example of Hugo splitted config can be found at https://github.com/razonyang/hugo-theme-bootstrap-skeleton/tree/main/config/_default
Frontmatter could allow a similar setup in .frontmatter/config
to allow an atomic configuration.
Another option is to allow the use of an import directive in frontmatter.json where the user explicitly import another file in lieu of a parameter value.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:25 (15 by maintainers)
Top GitHub Comments
Pushed the current change for the new beta. The feature is not yet complete, but already available to give it a try to see if weβre on the right path.
Current settings which can be split into folders/files are:
.frontmatter/config/taxonomy/contentTypes
.frontmatter/config/taxonomy/pageFolders
.frontmatter/config/taxonomy/placeholders
.frontmatter/config/taxonomy/snippets
Iβve also created a sample project: https://github.com/FrontMatter/project-samples/tree/main/docusaurus
Let me know what you think.
My only suggestion to the proposal outlined is that the convention always replace
.
with folder level, so instead of (not reordered for alphabetic sorting, sorry):It would be:
I think those three sections -
taxonomy.contentTypes
,content.snippets
, andcontent.placeholders
make enormous sense for a first pass. I think in the future it would absolutely be useful to be able to dodata.*
,taxonomy.fieldGroups
, andtaxonomy.customTaxonomy
.For me, the ideal end state is to be able to have most or all fields definable via this split definition, with non-arrays defined in their nearest ancestor
.json
. For example:With the deterministic file/folder name, we could know what schema to apply where.
On possible future DevX
In the example above, I used the full key names in the split config. To be very clear, I believe thatβs how this should be implemented initially because I expect itβs the least amount of work. However, I think a possible enhanced UX would be this instead:
But that would require some schema rework (or copying the schema partially and maintaining it separately, which seems rough - def more thought needs to go into the maintainability of something like this). I just wanted to note it here because if I didnβt do it now, I would entirely forget.
I really, really like this proposal. I also think sorting this out is something of a prerequisite for #407, especially since this model would make maintaining βpackagedβ configurations easier and will already require some work on merging. This is also much more relevant to the majority of the user base.
My own config file is 767 lines long without the hundreds of lines I would need for my data type definitions.