With 'Page Sections' or 'Blocks' in front matter data, there needs to be a way to define section/block templates and then manage a list/array of them in front matter.
To add, remove, change order of elements in the list and edit the front matter data in the block elements.
With 'Page Sections' or 'Blocks' in front matter data, there needs to be a way to define section/block templates and then manage a list/array of them in front matter.
To add, remove, change order of elements in the list and edit the front matter data in the block elements.
For an example see: https://forestry.io/blog/sawmill-layout-composer-for-hugo-and-forestry/#hugo-example
For a working example of this system in action see:
Website - https://psrfcu.org/
Repo - https://gitlab.com/psrfcu/psrfcu-2019/-/blob/master/content/_index.md
<!-- github-sync-id:1051651378 -->
Thanks @bwklein for the suggestion! The repo link you shared ends up on a 404 page. Would you be able to check the URL again? Once I can see how you are using it, I can understand the logic a bit better.
Thanks @bwklein for the suggestion! The repo link you shared ends up on a 404 page. Would you be able to check the URL again? Once I can see how you are using it, I can understand the logic a bit better.
<!-- github-comment-id:966921058 -->
Note, that with content files like this, there usually isn't any {{.Content}} in the body of the markdown file. Everything is defined in front matter variables to populate variables in the partials used to render the data into the page block.
It makes the site more like a traditional CMS where the information for the design components (blocks) is stored in the front matter data model and not all in markdown/html within the body of the content file.
Note, that with content files like this, there usually isn't any {{.Content}} in the body of the markdown file. Everything is defined in front matter variables to populate variables in the partials used to render the data into the page block.
It makes the site more like a traditional CMS where the information for the design components (blocks) is stored in the front matter data model and not all in markdown/html within the body of the content file.
<!-- github-comment-id:967357166 -->
Thank you for providing a sample! This makes it clear to me. As of what I can see this is specific to Forestry. I like the idea, but also think it's a bit abusing the front matter. Shortcodes would be a cleaner way and probably makes it better suitable for other SSGs.
Just to understand a couple of things. These page sections, where do you define these? I assume these are custom things you need to configure before they will be able to be used. Is that true?
Thank you for providing a sample! This makes it clear to me. As of what I can see this is specific to Forestry. I like the idea, but also think it's a bit abusing the front matter. Shortcodes would be a cleaner way and probably makes it better suitable for other SSGs.
Just to understand a couple of things. These page sections, where do you define these? I assume these are custom things you need to configure before they will be able to be used. Is that true?
<!-- github-comment-id:967452369 -->
Yes, essentially you make design elements or blocks in your partials directory. Then you have a layout type that reads through the front matter and for each 'page_section' it calls the appropriate 'block' and passes the data from that page_section array element into the partial. All of that would need to be setup first, to define what inputs are required for that block partial.
You also need to define the set of inputs for a particular block and use that for editing the data in the array of page_sections/blocks. In Forestry this is done with their Front Matter Templates, in Cloud Cannon this is done with array structures, see the attached file starting at line 80 for the Cloud Cannon array structures that match with the file I pasted above.
This approach works great in the situation where you want to reuse design elements on different pages and the editor can move them around and fill in the required information for each block as they 'assemble' the page from top to bottom.
In the site I posted the file for above, there are 19 different blocks that someone could build a page out of.
You are correct shortcodes could work too, but would make it difficult to reopen the editor for the block to make changes to an existing shortcode, unless you had a parser that would read the shortcode string and populate the snippet insertion UI with the values from the shortcode string. It seems like it would be a bit easier to define an array field type and a mini 'content type' for each 'block' that could be added into the array.
Yes, essentially you make design elements or blocks in your partials directory. Then you have a layout type that reads through the front matter and for each 'page_section' it calls the appropriate 'block' and passes the data from that page_section array element into the partial. All of that would need to be setup first, to define what inputs are required for that block partial.
```
{{- define "main" -}}
{{ $count := 0}}
{{- range .Params.page_sections -}}
{{ partial (printf "blocks/block-%s.html" .block) (dict "Section" . "Page" $ "section_count" $count ) }}
{{ $count = (add $count 1) }}
{{- end -}}
{{- end -}}
```
You also need to define the set of inputs for a particular block and use that for editing the data in the array of page_sections/blocks. In Forestry this is done with their Front Matter Templates, in Cloud Cannon this is done with array structures, see the attached file starting at line 80 for the Cloud Cannon array structures that match with the file I pasted above.
[cloudcannon.toml.zip](https://github.com/estruyf/vscode-front-matter/files/7530343/cloudcannon.toml.zip)
This approach works great in the situation where you want to reuse design elements on different pages and the editor can move them around and fill in the required information for each block as they 'assemble' the page from top to bottom.
In the site I posted the file for above, there are 19 different blocks that someone could build a page out of.
You are correct shortcodes could work too, but would make it difficult to reopen the editor for the block to make changes to an existing shortcode, unless you had a parser that would read the shortcode string and populate the snippet insertion UI with the values from the shortcode string. It seems like it would be a bit easier to define an array field type and a mini 'content type' for each 'block' that could be added into the array.
<!-- github-comment-id:967539169 -->
I think of shortcodes as a simple way to insert a smaller design element (figure, table, video, tweet) into the body of a larger Markdown file. Where this 'blocks' system is a way of composing entire pages from top to bottom, where each layer in the stack has a specific set of inputs to that specific layer.
I think of shortcodes as a simple way to insert a smaller design element (figure, table, video, tweet) into the body of a larger Markdown file. Where this 'blocks' system is a way of composing entire pages from top to bottom, where each layer in the stack has a specific set of inputs to that specific layer.
<!-- github-comment-id:967553463 -->
One thing to note is that shortcodes will NOT work within the content of a layer field. So you will see in my example file code that there are 'content_markdown' fields for some blocks. If you put a shortcode in there it won't render the shortcode result into the page, there will just be a shortcode string in the content of that block. You can 'markdownify' the content_markdown into HTML, but the shortcodes are ignored. There is an existing Hugo project issue to resolve this and allow for shortcodes in frontmatter text to be rendered.
One thing to note is that shortcodes will NOT work within the content of a layer field. So you will see in my example file code that there are 'content_markdown' fields for some blocks. If you put a shortcode in there it won't render the shortcode result into the page, there will just be a shortcode string in the content of that block. You can 'markdownify' the content_markdown into HTML, but the shortcodes are ignored. There is an existing Hugo project issue to resolve this and allow for shortcodes in frontmatter text to be rendered.
<!-- github-comment-id:967559099 -->
@estruyf this has become a blocker for me. I can't use it on sites where I have arrays of data in Front Matter. Do you have any suggestions for a workaround, or ideas on how to implement this in FM?
@estruyf this has become a blocker for me. I can't use it on sites where I have arrays of data in Front Matter. Do you have any suggestions for a workaround, or ideas on how to implement this in FM?
<!-- github-comment-id:1008913904 -->
@zivbk1 added it to the board for the next release. At the moment there is no workaround for it. Think it is best to start with #197
@zivbk1 added it to the board for the next release. At the moment there is no workaround for it. Think it is best to start with #197
<!-- github-comment-id:1009034615 -->
@zivbk1 does #197 get this supported as well? Or are there missing pieces still?
I think it is closer, but the missing piece is a field type in a template where you can choose from a set of defined data structures to add them into an array in the front matter. Do the examples above help or should I setup a more simple example/test for this feature?
> @zivbk1 does #197 get this supported as well? Or are there missing pieces still?
I think it is closer, but the missing piece is a field type in a template where you can choose from a set of defined data structures to add them into an array in the front matter. Do the examples above help or should I setup a more simple example/test for this feature?
<!-- github-comment-id:1012987087 -->
My two cents - I use Forestry Blocks for a two client sites (Hugo) and one personal(Pelican) to allow the users a familiar front end to contribute content and build pages. Their "Blocks" feature is a game changer for changing pages. I thought about asking for this feature also, but I could not even think of how it would take advantage of the existing FM UI without a modal/dialog box and my Pelican sites don't use shortcodes, so I did not propose them.
If it can happen that would be cool if not I might just make project level snippets.
My two cents - I use Forestry Blocks for a two client sites (Hugo) and one personal(Pelican) to allow the users a familiar front end to contribute content and build pages. Their "Blocks" feature is a game changer for changing pages. I thought about asking for this feature also, but I could not even think of how it would take advantage of the existing FM UI without a modal/dialog box and my Pelican sites don't use shortcodes, so I did not propose them.
If it can happen that would be cool if not I might just make project level snippets.
<!-- github-comment-id:1019217917 -->
Project level snippets is going to be the next major improvement for Front Matter, this is certain
There needs to be a benefit of using these over what VS Code provides by default. We're thinking about:
allowing you to add snippets
visualising all snippets on a dashboard
dialog to insert placeholders, which include inputs/choices/...
One thing that would make it great, is to have a way to get easily update the snippets that are already defined in the content.
About the list field, I've been thinking of using the same data field schema (JSON schema) which is used in the new data view.
Project level snippets is going to be the next major improvement for Front Matter, this is certain
There needs to be a benefit of using these over what VS Code provides by default. We're thinking about:
- allowing you to add snippets
- visualising all snippets on a dashboard
- dialog to insert placeholders, which include inputs/choices/...
One thing that would make it great, is to have a way to get easily update the snippets that are already defined in the content.
About the list field, I've been thinking of using the same data field schema (JSON schema) which is used in the new data view.
<!-- github-comment-id:1019224537 -->
About the list field, I've been thinking of using the same data field schema (JSON schema) which is used in the new data view.
i am still not familiar with json and the scheme technics. Hopefully this project may clarify some aspects of using json and json schemes.
i am thinking of the Specifications that are announced on the Specification documents on the JSON Schema org.
Versioning and looking forward is nice, but if you are out of date it may be getting complicated to be up to date. telling it from a perspective of an unemployed who stucks learning after some issues.
Which schema is the right one? Should this be hardcoded somehow, or would/should be let over to the developer?
i am getting overhelmed trying to find ressources for a clear explanation for json schemes, it looks realy fluent. but, it is a nice solution, but for me not clear enough right now.
also yaml is explaining itself as a clear solution, binding both together with a clean solution might be helpfull.
yaml to json schema and json data, and also json schema and json data to yaml? decide :-) well i need some vacation :-)
@estruyf yes that are nice features.
> About the list field, I've been thinking of using the same data field schema (JSON schema) which is used in the new data view.
i am still not familiar with json and the scheme technics. Hopefully this project may clarify some aspects of using json and json schemes.
i am thinking of the Specifications that are announced on the Specification documents on the JSON Schema org.
Versioning and looking forward is nice, but if you are out of date it may be getting complicated to be up to date. telling it from a perspective of an unemployed who stucks learning after some issues.
Which schema is the right one? Should this be hardcoded somehow, or would/should be let over to the developer?
i am getting overhelmed trying to find ressources for a clear explanation for json schemes, it looks realy fluent. but, it is a nice solution, but for me not clear enough right now.
also yaml is explaining itself as a clear solution, binding both together with a clean solution might be helpfull.
yaml to json schema and json data, and also json schema and json data to yaml? decide :-) well i need some vacation :-)
<!-- github-comment-id:1019348786 -->
@wemasoe the version of the JSON schema does only matter when you are going to create really complicated data types. If you only need a couple of data fields, the schema is "pretty" easy to understand. There is always a trade-off with each road picked or decision.
The same goes for YAML, it is easy to understand, but this is just the data representation. When you would create a YAML schema to define the data structure, it would also mean you need to think it through a bit and do some trial and error.
Another reason why JSON Schema has been taken is that VS Code its settings are JSON driven and this keeps it all aligned.
Future
If we get more contributors on board, or if I manage to make more time available, one of the ideas that are on the backlog is to create a content type/settings dashboard (#129). This could become a drag and drop kind functionality to create data types and content types. Which eventually might make it easier for any that is not familiar with it.
@wemasoe the version of the JSON schema does only matter when you are going to create really complicated data types. If you only need a couple of data fields, the schema is "pretty" easy to understand. There is always a trade-off with each road picked or decision.
The same goes for YAML, it is easy to understand, but this is just the data representation. When you would create a YAML schema to define the data structure, it would also mean you need to think it through a bit and do some trial and error.
Another reason why JSON Schema has been taken is that VS Code its settings are JSON driven and this keeps it all aligned.
**Future**
If we get more contributors on board, or if I manage to make more time available, one of the ideas that are on the backlog is to create a content type/settings dashboard (#129). This could become a drag and drop kind functionality to create data types and content types. Which eventually might make it easier for any that is not familiar with it.
<!-- github-comment-id:1019455554 -->
@wemasoe the version of the JSON schema does only matter when you are going to create really complicated data types. If you only need a couple of data fields, the schema is "pretty" easy to understand. There is always a trade-off with each road picked or decision.
The same goes for YAML, it is easy to understand, but this is just the data representation. When you would create a YAML schema to define the data structure, it would also mean you need to think it through a bit and do some trial and error.
Another reason why JSON Schema has been taken is that VS Code its settings are JSON driven and this keeps it all aligned.
Future
If we get more contributors on board, or if I manage to make more time available, one of the ideas that are on the backlog is to create a content type/settings dashboard (#129). This could become a drag and drop kind functionality to create data types and content types. Which eventually might make it easier for any that is not familiar with it.
step by step, everything is going to be good
i have to say the vscode extension Front Matter is a nice project, again, again, again.
> @wemasoe the version of the JSON schema does only matter when you are going to create really complicated data types. If you only need a couple of data fields, the schema is "pretty" easy to understand. There is always a trade-off with each road picked or decision.
>
> The same goes for YAML, it is easy to understand, but this is just the data representation. When you would create a YAML schema to define the data structure, it would also mean you need to think it through a bit and do some trial and error.
>
> Another reason why JSON Schema has been taken is that VS Code its settings are JSON driven and this keeps it all aligned.
>
> **Future**
>
> If we get more contributors on board, or if I manage to make more time available, one of the ideas that are on the backlog is to create a content type/settings dashboard (#129). This could become a drag and drop kind functionality to create data types and content types. Which eventually might make it easier for any that is not familiar with it.
step by step, everything is going to be good
i have to say the vscode extension Front Matter is a nice project, again, again, again.
<!-- github-comment-id:1019513711 -->
@zivbk1 does #197 get this supported as well? Or are there missing pieces still?
I think it is closer, but the missing piece is a field type in a template where you can choose from a set of defined data structures to add them into an array in the front matter. Do the examples above help or should I setup a more simple example/test for this feature?
@estruyf does this help clarify the need or should I provide a better example?
Here is an example of the definition of that 'page' content type. Where there are two choices (for brevity) that can be 'added' into the page_sections front matter array of a 'page' content type.
After building that data structure, it seems like it would be nice to define choice arrays somewhere else in the config file that can be reused by referring to them by name. Like a background color and text color set of options that can be used in different choice fields to keep things DRY.
> > @zivbk1 does #197 get this supported as well? Or are there missing pieces still?
>
> I think it is closer, but the missing piece is a field type in a template where you can choose from a set of defined data structures to add them into an array in the front matter. Do the examples above help or should I setup a more simple example/test for this feature?
@estruyf does this help clarify the need or should I provide a better example?
I have begun setting up a Hugo starter that uses this method of page building. https://gitlab.com/zivbk1/hugostarter
You can see in that project that there are already 2 'blocks' that a person can use to build a page.
https://gitlab.com/zivbk1/hugostarter/-/tree/main/layouts/partials/blocks
You can see here the code that is used to take the frontmatter of a page and call the correct block partial into place from top to bottom of the page. https://gitlab.com/zivbk1/hugostarter/-/blob/main/layouts/_default/page.html
Finally, you can see in this file where both blocks are called into the page from the `page_sections` array.
https://gitlab.com/zivbk1/hugostarter/-/blob/main/content/_index.md
Here is an example of the definition of that 'page' content type. Where there are two choices (for brevity) that can be 'added' into the `page_sections` front matter array of a 'page' content type.
```
"frontMatter.taxonomy.contentTypes": [
{
"name": "page",
"fileType": "md",
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime"
},
{
"title": "Article preview",
"name": "featured_image",
"type": "image",
"isPreviewImage": true
},
{
"title": "Is in draft",
"name": "draft",
"type": "draft"
},
{
"title": "Page Sections",
"name": "page_sections",
"type": "choice",
"multiple": true,
"choices": [
{
"icon": "hail",
"title": "Hero Banner",
"fields": [
{
"title": "Page Block",
"name": "block",
"type": "string",
"hidden": true,
"default": "hero"
},
{
"title": "Hero Text",
"name": "heading",
"type": "string"
},
{
"title": "Background Color",
"name": "background_color",
"type": "choice",
"choices": [
{
"id": "white",
"title": "White"
},
{
"id": "green",
"title": "Green"
},
{
"id": "black",
"title": "Black"
}
]
},
{
"title": "Text Color",
"name": "text_color",
"type": "choice",
"choices": [
{
"id": "white",
"title": "White"
},
{
"id": "green",
"title": "Green"
},
{
"id": "black",
"title": "Black"
}
]
}
]
},
{
"icon": "newspaper",
"title": "Markdown Content",
"fields": [
{
"title": "Page Block",
"name": "block",
"type": "string",
"hidden": true,
"default": "content"
}
]
}
]
}
]
}
]
```
In this context, any 'icon' defined would be pulled from something like https://fonts.google.com/icons?selected=Material+Icons
After building that data structure, it seems like it would be nice to define choice arrays somewhere else in the config file that can be reused by referring to them by name. Like a background color and text color set of options that can be used in different choice fields to keep things DRY.
<!-- github-comment-id:1030721378 -->
To add to my comment above. It would be nice to see the list of page sections in the UI in an expandable accordion or something like that, where the order of the array can be changed and then edited in the expanded accordion space below the heading or maybe an editing modal that opens for that specific data item in the array. It would also be good to identify what field in the block you want to show in the stacked list of page_sections, similar to "labelField" in the data file definition. This is where it would be nice to just show the icon and then the text for the "labelField".
A lot of what I am talking about seems very similar to how the data file editor works now. Maybe use a similar UI with the stack of sections similar to the array of data items in a data file, and a very similar order and editing UI for those sections.
To add to my comment above. It would be nice to see the list of page sections in the UI in an expandable accordion or something like that, where the order of the array can be changed and then edited in the expanded accordion space below the heading or maybe an editing modal that opens for that specific data item in the array. It would also be good to identify what field in the block you want to show in the stacked list of page_sections, similar to "labelField" in the data file definition. This is where it would be nice to just show the icon and then the text for the "labelField".
A lot of what I am talking about seems very similar to how the data file editor works now. Maybe use a similar UI with the stack of sections similar to the array of data items in a data file, and a very similar order and editing UI for those sections.
<!-- github-comment-id:1030722266 -->
Still work in progress, but this is what the new collection data field looks like:
Still work in progress, but this is what the new collection data field looks like:

<!-- github-comment-id:1035372838 -->
In the frontMatter.data.types, you can define your data type to use for the collection.
Style changes + some fixes have been added. Just committed the first version of the new control.
In order to use it, you'll need to define the field in your content type as follows:
```json
{
"title": "Page sections",
"name": "page_sections",
"type": "data-collection",
"dataType": "page_sections2"
}
```
In the `frontMatter.data.types`, you can define your data type to use for the collection.


<!-- github-comment-id:1036062185 -->
Can "dataType": "page_sections2" be set up as a list of data types that can be added into the Record set?
In most use cases there would be different 'blocks' or data structures that would be added to the list of records. Where in your example 'Record 1' would be one data type, 'Record 2' would be another, and so on.
Also, would there be an ability to reorder the list, to put Record 3 above Record 1?
This is some example frontmatter that I would want to make work.
title: Hello World
date: 2022-02-04T21:48:46.000Z
draft: true
layout: page
page_sections:
- block: hero
heading_markdown: Hello World
background_choice: gray
text_choice: white
- block: content
type: page
lastmod: '2022-02-04T23:52:45.963Z'
Where the first 'block' or record in the array has a data structure that includes the fields, block, heading_markdown, background_choice, text_choice and a second data type that only contains the field block set to the default value of 'content'.
Can "dataType": "page_sections2" be set up as a list of data types that can be added into the Record set?
In most use cases there would be different 'blocks' or data structures that would be added to the list of records. Where in your example 'Record 1' would be one data type, 'Record 2' would be another, and so on.
Also, would there be an ability to reorder the list, to put Record 3 above Record 1?
This is some example frontmatter that I would want to make work.
```
title: Hello World
date: 2022-02-04T21:48:46.000Z
draft: true
layout: page
page_sections:
- block: hero
heading_markdown: Hello World
background_choice: gray
text_choice: white
- block: content
type: page
lastmod: '2022-02-04T23:52:45.963Z'
```
Where the first 'block' or record in the array has a data structure that includes the fields, `block`, `heading_markdown`, `background_choice`, `text_choice` and a second data type that only contains the field `block` set to the default value of 'content'.
<!-- github-comment-id:1036461171 -->
If it can be defined in a JSON schema, it will be possible, but having different data types, loaded in the data collection field is not “yet” possible.
Technically it’s possible, I first focused on the main collection functionality and getting the fields right
1. If it can be defined in a JSON schema, it will be possible, but having different data types, loaded in the data collection field is not “yet” possible.
2. Technically it’s possible, I first focused on the main collection functionality and getting the fields right
<!-- github-comment-id:1036471129 -->
Been thinking, so if the dataType can contain multiple data types, we could for instance show first a dropdown that allows you to select the type. Once you choose the type, it will show the additional data type's fields.
In order for this to work, we need to have an id field that corresponds to the data type you picked. Otherwise, it would be guessing which one you took. In your case, it is block, could we change it to type? That way it would be a bit more generic.
Been thinking, so if the dataType can contain multiple data types, we could for instance show first a dropdown that allows you to select the type. Once you choose the type, it will show the additional data type's fields.
In order for this to work, we need to have an `id` field that corresponds to the data type you picked. Otherwise, it would be guessing which one you took. In your case, it is `block`, could we change it to `type`? That way it would be a bit more generic.
<!-- github-comment-id:1036632299 -->
FWIW - In my forestry setups I use template and it works, so I don't think using type will be an issue. A generic term is probably the best way to go.
FWIW - In my forestry setups I use `template` and it works, so I don't think using type will be an issue. A generic term is probably the best way to go.
<!-- github-comment-id:1037484797 -->
Thanks for the feedback! Have been coding during my flight. Will commit the changes later.
Changed it to data blocks and block types. When configuring, you can select one type or many. Once you pick many, you'll need select the type to use and add the data.
Hope it will make sense.
Thanks for the feedback! Have been coding during my flight. Will commit the changes later.
Changed it to data blocks and block types. When configuring, you can select one type or many. Once you pick many, you'll need select the type to use and add the data.
Hope it will make sense.
<!-- github-comment-id:1037487369 -->
Changed it to data blocks and block types. When configuring, you can select one type or many. Once you pick many, you'll need select the type to use and add the data.
This makes perfect sense to me.
> Changed it to data blocks and block types. When configuring, you can select one type or many. Once you pick many, you'll need select the type to use and add the data.
This makes perfect sense to me.
<!-- github-comment-id:1037504719 -->
The field will need to be configured as follows:
```json
{
"title": "Page sections",
"name": "page_sections",
"type": "block",
"blockType": "type1"
}
```
or
```json
{
"title": "Page sections",
"name": "page_sections",
"type": "block",
"blockType": ["type1", "type2"]
}
```
<!-- github-comment-id:1038232656 -->
"frontMatter.taxonomy.contentTypes":[{"name":"page","fields":[{"title":"Page sections","name":"page_sections","type":"block","blockType":["test2","test3"]},{"title":"Is in draft","name":"draft","type":"draft"},{"title":"Title","name":"title","type":"string"},...]}]
@apowell656 you will need two things:
1. A data type defined in the `frontMatter.data.types` settings
2. A content type with the `block` field defined
**frontMatter.data.types - setting**
```json
"frontMatter.data.types": [
{
"id": "test2",
"schema": {
"type": "object",
"required": [
"name",
"url"
],
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"url": {
"type": "string",
"title": "URL"
}
}
}
},
{
"id": "test3",
"schema": {
"type": "object",
"properties": {
"block": {
"type": "string",
"title": "Block"
},
"name": {
"type": "string",
"title": "Name"
}
}
}
}
]
```
**frontMatter.taxonomy.contentTypes - setting**
```json
"frontMatter.taxonomy.contentTypes": [
{
"name": "page",
"fields": [
{
"title": "Page sections",
"name": "page_sections",
"type": "block",
"blockType": ["test2", "test3"]
},
{
"title": "Is in draft",
"name": "draft",
"type": "draft"
},
{
"title": "Title",
"name": "title",
"type": "string"
},
...
]
}
]
```
<!-- github-comment-id:1038293136 -->
@estruyf that put me on the right track. I looked into the documentation to get me across the finish line, but I think I am missing something. Do I need to create a data.type for each "block"/template? I tried changing the template to block in the page_sections with the same result.
@estruyf that put me on the right track. I looked into the documentation to get me across the finish line, but I think I am missing something. Do I need to create a data.type for each "block"/template? _I tried changing the template to block in the page_sections with the same result._
<img width="449" alt="template-layout" src="https://user-images.githubusercontent.com/1969515/153770445-6f9ddcff-a8cd-4bce-9350-900ce13018e3.png">
<img width="286" alt="page-sections" src="https://user-images.githubusercontent.com/1969515/153770448-29c572c7-bdce-4748-bde7-3104b7536458.png">
<img width="955" alt="content-settings" src="https://user-images.githubusercontent.com/1969515/153770452-ffe9623e-9557-420e-af38-59e8d204ea89.png">
<img width="486" alt="data-type" src="https://user-images.githubusercontent.com/1969515/153770454-4667f77b-d12d-4a82-bf64-a2e5137310ee.png">
<!-- github-comment-id:1038352889 -->
@apowell656 yes, you'll have to specify what your block looks like, otherwise, it is a bit hard to render the form.
To compare it to Forestry:
The data type you define is the repeatable field;
The block field you define in the content type, is like the block field you define in Forestry, but instead of liking a field(s) to it, you like a data type to it.
@apowell656 yes, you'll have to specify what your block looks like, otherwise, it is a bit hard to render the form.
To compare it to Forestry:
- The data type you define is the repeatable field;
- The block field you define in the content type, is like the block field you define in Forestry, but instead of liking a field(s) to it, you like a data type to it.
<!-- github-comment-id:1038381382 -->
I don't want the editor to change that field and break the page.
NOTE: I get "Error loading field" now if I add these.
Also, is it possible to use the "default" and "hidden" properties for a particular field?
For example, to always set `blockType: hero` in a page_section block.
```
"blockType": {
"type": "string",
"title": "Block Template",
"default": "hero",
"hidden": true
}
```
I don't want the editor to change that field and break the page.
NOTE: I get "Error loading field" now if I add these.
<!-- github-comment-id:1038395311 -->
I am getting an "Error loading field" error when trying to use the 'choice' field type in a block the data type definition.
@zivbk1 that is because it is a JSON schema and the types need to be valid JSON known types: string, number, boolean, object, array. Custom types are not "yet" supported. It is doable to create custom types, but it means that there need to be custom renderers created for each new type. We probably need image and DateTime support as well.
In case of the choices, you can use the following:
> I am getting an "Error loading field" error when trying to use the 'choice' field type in a block the data type definition.
@zivbk1 that is because it is a JSON schema and the `types` need to be valid JSON known types: `string, number, boolean, object, array`. Custom types are not "yet" supported. It is doable to create custom types, but it means that there need to be custom renderers created for each new type. We probably need image and DateTime support as well.
In case of the choices, you can use the following:
```JSON
{
"title": "Background Color",
"type": "choice",
"enum": ["Black", "Blue", "Gray"]
}
```
<!-- github-comment-id:1038398395 -->
It might be good to not show the 'blockType' field in a page_section at all. I can't think of a use case where someone would want to edit that. If you want to change the blockType, then just add another block to the list of the correct type and delete the current one that is the wrong type.
It might be good to not show the 'blockType' field in a page_section at all. I can't think of a use case where someone would want to edit that. If you want to change the blockType, then just add another block to the list of the correct type and delete the current one that is the wrong type.
<!-- github-comment-id:1038399647 -->
Basically, anything you can do in the frontmatter UI, you could do within a block editor. Same field types, UI and functions.
Basically, anything you can do in the frontmatter UI, you could do within a block editor. Same field types, UI and functions.
<!-- github-comment-id:1038401479 -->
Also, is it possible to use the "default" and "hidden" properties for a particular field?
Yes, this is supported, but you should not be doing it for the blockType field, as that is automatically done by the extension.
It might be good to not show the 'blockType' field in a page_section at all. I can't think of a use case where someone would want to edit that. If you want to change the blockType, then just add another block to the list of the correct type and delete the current one that is the wrong type.
So, once a block has been created, you would only be able to move it or delete it?
> Also, is it possible to use the "default" and "hidden" properties for a particular field?
Yes, this is supported, but you should not be doing it for the `blockType` field, as that is automatically done by the extension.
> It might be good to not show the 'blockType' field in a page_section at all. I can't think of a use case where someone would want to edit that. If you want to change the blockType, then just add another block to the list of the correct type and delete the current one that is the wrong type.
So, once a block has been created, you would only be able to move it or delete it?
<!-- github-comment-id:1038402297 -->
Okay, I like my tests. Final question is it possible to nest an array? I have a template that has nested paragraphs (about-section) I am mentally halfway paying attention D@&n Super Bowl.
Okay, I like my tests. Final question is it possible to nest an array? I have a template that has nested paragraphs (about-section) _I am mentally halfway paying attention D@&n Super Bowl._

<!-- github-comment-id:1038408414 -->
Basically, anything you can do in the frontmatter UI, you could do within a block editor. Same field types, UI and functions.
That is indeed what is needed. Also thinking about another option to extend the field field type. Right now it supports to only specified sub-fields, but what if we extend the field to allow field-bundle choices.
Maybe this block field, would better become a collection field, like how I initially had it in mind. As it allows you to reuse the data types from your data files/folders.
The block field, becomes a field type that allows you to do the same as what is defined above, but instead of specifying a data type, you specify a field block.
field block would be a new setting, that comes with an ID and fields (all the fields from Front Matter are supported).
This might be the best option after all. I might have been overthinking it due to the discussion we had about the file data/folders previously.
> Basically, anything you can do in the frontmatter UI, you could do within a block editor. Same field types, UI and functions.
That is indeed what is needed. Also thinking about another option to extend the `field` field type. Right now it supports to only specified sub-fields, but what if we extend the field to allow field-bundle choices.
Maybe this `block` field, would better become a `collection` field, like how I initially had it in mind. As it allows you to reuse the data types from your data files/folders.
The `block` field, becomes a field type that allows you to do the same as what is defined above, but instead of specifying a data type, you specify a `field block`.
`field block` would be a new setting, that comes with an ID and fields (all the fields from Front Matter are supported).
This might be the best option after all. I might have been overthinking it due to the discussion we had about the file data/folders previously.
<!-- github-comment-id:1038408757 -->
I actually love this new direction and it is closer to what I originally had in mind too.
I really just want a way to define 'blocks' (a configured selection of fields) and then have a way of picking from the defined set of blocks and adding them into an array ('page_sections' as an example of the array/collection name).
Once in the array, I can edit, move its position in the collection and delete them from the collection.
I actually love this new direction and it is closer to what I originally had in mind too.
I really just want a way to define 'blocks' (a configured selection of fields) and then have a way of picking from the defined set of blocks and adding them into an array ('page_sections' as an example of the array/collection name).
Once in the array, I can edit, move its position in the collection and delete them from the collection.
<!-- github-comment-id:1038410979 -->
Also, it would be nice to specify a field in the field block to use as the text for the item in the list of blocks that have been added to the array. So the 'Title' of the field_block might be 'Hero Banner' as the label for selecting the correct block from the list. Then there is a 'heading' field in the block that you would like to see in the label for the block in the collection.
This way you can determine which 'hero' in the page_sections collection is the one that has the text you want to edit.
Also, it would be nice to specify a field in the `field block` to use as the text for the item in the list of blocks that have been added to the array. So the 'Title' of the `field_block` might be 'Hero Banner' as the label for selecting the correct block from the list. Then there is a 'heading' field in the `block` that you would like to see in the label for the block in the collection.
This way you can determine which 'hero' in the `page_sections` collection is the one that has the text you want to edit.
<!-- github-comment-id:1038415472 -->
So, once a block has been created, you would only be able to move it or delete it?
Yes, you can edit the contents of the block, change the order in the collection and delete it. I just don't want to be able to modify the block identification field (whatever it is called). Because that field is used to determine the 'field_block' template to use and determine the Hugo partial to render that section in the page. All of the other fields in the block are editable.
> So, once a block has been created, you would only be able to move it or delete it?
Yes, you can edit the contents of the block, change the order in the collection and delete it. I just don't want to be able to modify the block identification field (whatever it is called). Because that field is used to determine the 'field_block' template to use and determine the Hugo partial to render that section in the page. All of the other fields in the block are editable.
<!-- github-comment-id:1038417377 -->
> All - would anyone be willing to share a sample of usage?
Here is a super basic demo. Where the main index page uses blocks.
https://gitlab.com/zivbk1/hugostarter
<!-- github-comment-id:1039189629 -->
You'll have to change type to json, and blockType to dataType.
Currently, the new block field is in development.
@apowell656 @zivbk1 the `block` field will now be the `json` field.
In the example of @zivbk1 - https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L55-63
```json
{
"title": "Page Sections",
"name": "page_sections",
"type": "block",
"blockType": [
"hero",
"content"
]
}
```
You'll have to change `type` to `json`, and `blockType` to `dataType`.
Currently, the new `block` field is in development.
<!-- github-comment-id:1039227269 -->
@estruyf thank you. I'll update this demo project when blocks are ready. What use case do you anticipate for the json type?
@estruyf thank you. I'll update this demo project when blocks are ready. What use case do you anticipate for the json type?
<!-- github-comment-id:1039247103 -->
@estruyf and @zivbk1 thanks for links. I have validated my JSON to use nested content (my fields without nested content are working well), but the result is the error Error loading field1. The documentation is not fleshed out well enough to explain if I can do this for data.types` is that the case.
@estruyf and @zivbk1 thanks for links. I have validated my JSON to use nested content (my fields without nested content are working well), but the result is the error `Error loading field1. The documentation is not fleshed out well enough to explain if I can do this for `data.types` is that the case.
<!-- github-comment-id:1039267031 -->
@estruyf thank you. I'll update this demo project when blocks are ready. What use case do you anticipate for the json type?
Just there in case you want to reuse the data types you already have defined. As it was already developed, I didn't want to remove it.
> @estruyf thank you. I'll update this demo project when blocks are ready. What use case do you anticipate for the json type?
Just there in case you want to reuse the data types you already have defined. As it was already developed, I didn't want to remove it.
<!-- github-comment-id:1039271583 -->
@estruyf and @zivbk1 thanks for links. I have validated my JSON to use nested content (my fields without nested content are working well), but the result is the error Error loading field1. The documentation is not fleshed out well enough to explain if I can do this for data.types` is that the case.
This has probably to do with an invalid JSON schema. Once the new block field is ready, I hope it will make it easier.
> @estruyf and @zivbk1 thanks for links. I have validated my JSON to use nested content (my fields without nested content are working well), but the result is the error `Error loading field1. The documentation is not fleshed out well enough to explain if I can do this for `data.types` is that the case.
This has probably to do with an invalid JSON schema. Once the new `block` field is ready, I hope it will make it easier.
<!-- github-comment-id:1039273393 -->
Also, for some UI/UX feedback. The gray input fields and the gray text on the buttons made me think at first that they we 'inactive' or 'read-only'. I would make the inputs have a gray border only and use white text for the buttons.
Also, for some UI/UX feedback. The gray input fields and the gray text on the buttons made me think at first that they we 'inactive' or 'read-only'. I would make the inputs have a gray border only and use white text for the buttons.

<!-- github-comment-id:1039287849 -->
Once you did this configuration, it will render a similar experience to the JSON data collection field, but with the default field like you are used to.
Note
: the frontMatter.taxonomy.fieldGroups setting is not yet in the schema, so your editor might complain about it. Once it is tested and proven to be working, it will get added.
Ok, think the first version of the `block` type is ready to be tested.
**Configuration**
1. A new setting is required:
```json
"frontMatter.taxonomy.fieldGroups": [
{
"id": "Highlight",
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
}
]
},
{
"id": "Extra",
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Extra",
"name": "extra",
"type": "string"
}
]
}
]
```
> **Important**: This field group can hold the same field configuration as you typically do on the content type. All fields should be supported.
2. Update your content type field to this:
```json
"frontMatter.taxonomy.contentTypes": [
{
"name": "page",
"fields": [
{
"title": "Page sections",
"name": "page_sections",
"type": "block",
"fieldGroup": ["Highlight", "Extra"]
},
```
Once you did this configuration, it will render a similar experience to the `JSON` data collection field, but with the default field like you are used to.
> **Note**: the `frontMatter.taxonomy.fieldGroups` setting is not yet in the schema, so your editor might complain about it. Once it is tested and proven to be working, it will get added.
<!-- github-comment-id:1039350724 -->
I think you can remove the words 'your' and 'value' from the selection field placeholder text.
I think you can remove the words 'your' and 'value' from the selection field placeholder text.

<!-- github-comment-id:1039384814 -->
I have added a 'Kitchen Sink' field group ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L189 ) to test all of the field types and I am having some trouble with two of the types. This is the 'content' file for the test ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/content/_index.md ).
- 'custom taxonomy' - 'feelings' ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L259 ) which shows a list of the feelings in the UI ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L215 ), but when I pick one it doesn't save it to the 'feeling' field in the file's front matter. It flashes for a moment and then nothing is selected or added to the file.
- 'fields' - 'photo' ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L220 ) which doesn't show up in the UI at all.
<!-- github-comment-id:1039487970 -->
The support for 'fields' field is kind of working, I now see it in the UI and can edit the 'Title' text. But I am having some trouble with the image part. It opens up the media viewer and I can click the 'plus' icon to insert, but then the UI on the left flashes, closes the block I was editing and the image path is not added to the 'image' field. See this happen in the video below.
If I add the path to an 'image' field directly in the file front matter, I get an error about how the image cannot be loaded.
The support for 'fields' field is kind of working, I now see it in the UI and can edit the 'Title' text. But I am having some trouble with the image part. It opens up the media viewer and I can click the 'plus' icon to insert, but then the UI on the left flashes, closes the block I was editing and the image path is not added to the 'image' field. See this happen in the video below.
https://user-images.githubusercontent.com/12104446/153953117-5af9d536-85ea-4e65-a209-bb91517ea639.mp4
If I add the path to an 'image' field directly in the file front matter, I get an error about how the image cannot be loaded.
<!-- github-comment-id:1039610028 -->
Why not just make that a single field that you can write markdown in and let the processor turn that into paragraphs in HTML for you?
@apowell656
> I have a template that has nested paragraphs...
Why not just make that a single field that you can write markdown in and let the processor turn that into paragraphs in HTML for you?
<!-- github-comment-id:1039617864 -->
@bwklein that sounds like a solve. Honestly, did not think of that and as I am typing I realize the oversight ;-).
@bwklein that sounds like a solve. Honestly, did not think of that and as I am typing I realize the oversight ;-).
<!-- github-comment-id:1039622388 -->
@apowell656 one thing to be careful of in Hugo (if you are using it) is that currently shortcodes will not work in front matter content like that. There is an old issue in the Hugo project about it.
@apowell656 one thing to be careful of in Hugo (if you are using it) is that currently shortcodes will not work in front matter content like that. There is an old issue in the Hugo project about it.
<!-- github-comment-id:1039624281 -->
@bwklein I think I may still have the same problem for other sections of my template for example:
- block: about-section
title: About the Chris and Andre Show
paragraphs:
- content: 'You can find a podcast topic on just about anything and, if you are lucky, a podcast that covers things you are interested in. The Chris and Andre Show is different (we are sure you have heard that before) because we talk about things we would talk about even if we weren’t recording.'
- content: 'When we worked together at the infamous “EArea” during lunch, we would talk about anything. And we mean anything. From religion to the latest movie, getting all the buzz. Chris with his puns and Andre with his reserved tone often gathered an audience of people who often took part.'
- content: We invite you to join us as we continue these conversations and a chance to do life with us. Unfiltered and honest conversations with two friends who try to make each other better one conversation at a time.
authors:
- name: Chris Smith
image: /assets/img/chris.jpg
tagline: I want some burgers and fries!
details: 'A self-proclaimed “pop-culture expert,” Chris excels at relating any conversation to some obscure reference. He can also rattle off a number of useless football statistics, especially i›f it’s NC State related. Chris lives with his beautiful wife, Christie, his talented daughter, Helena, and their lovable dogs, Ambrose and Cerberus.'
social:
- name: Twitter
logo: fab fa-twitter
url: 'https://twitter.com/Chim77Richalds'
- name: Instagram
logo: fab fa-instagram
url: 'https://www.instagram.com/eatin__vegan/'
- name: André Powell
image: /assets/img/andre.jpg
tagline: I am Iron Man
details: 'Has a lot of opinions, but really likes to listen. André is into "most" things sports and if the team is from NY, there is a 98% chance he is a fan. In recent years he came out as a "geek" and is into "most" things tech. André lives with his wife, while arm-chair quarterbacking for his four adult sons and his favorite daughter.'
social:
- name: Website
logo: fas fa-globe
url: 'https://andre.powells.page'
Your proposal solves the paragraphs section, but having a true repeatable field (example:authors) will be a problem, unless I break everything down into smaller components which is contradicting to DRY IMO.
@bwklein I think I may still have the same problem for other sections of my template for example:
```
- block: about-section
title: About the Chris and Andre Show
paragraphs:
- content: 'You can find a podcast topic on just about anything and, if you are lucky, a podcast that covers things you are interested in. The Chris and Andre Show is different (we are sure you have heard that before) because we talk about things we would talk about even if we weren’t recording.'
- content: 'When we worked together at the infamous “EArea” during lunch, we would talk about anything. And we mean anything. From religion to the latest movie, getting all the buzz. Chris with his puns and Andre with his reserved tone often gathered an audience of people who often took part.'
- content: We invite you to join us as we continue these conversations and a chance to do life with us. Unfiltered and honest conversations with two friends who try to make each other better one conversation at a time.
authors:
- name: Chris Smith
image: /assets/img/chris.jpg
tagline: I want some burgers and fries!
details: 'A self-proclaimed “pop-culture expert,” Chris excels at relating any conversation to some obscure reference. He can also rattle off a number of useless football statistics, especially i›f it’s NC State related. Chris lives with his beautiful wife, Christie, his talented daughter, Helena, and their lovable dogs, Ambrose and Cerberus.'
social:
- name: Twitter
logo: fab fa-twitter
url: 'https://twitter.com/Chim77Richalds'
- name: Instagram
logo: fab fa-instagram
url: 'https://www.instagram.com/eatin__vegan/'
- name: André Powell
image: /assets/img/andre.jpg
tagline: I am Iron Man
details: 'Has a lot of opinions, but really likes to listen. André is into "most" things sports and if the team is from NY, there is a 98% chance he is a fan. In recent years he came out as a "geek" and is into "most" things tech. André lives with his wife, while arm-chair quarterbacking for his four adult sons and his favorite daughter.'
social:
- name: Website
logo: fas fa-globe
url: 'https://andre.powells.page'
```
Your proposal solves the `paragraphs` section, but having a true repeatable field (example:authors) will be a problem, unless I break everything down into smaller components which is contradicting to DRY IMO.
<!-- github-comment-id:1039629856 -->
@apowell656 Are you using field groups for your social array? I think that you could also use the new json type for that too.
I'll try to assemble a quick demo of each option.
> same problem for other sections of my template
@apowell656 Are you using field groups for your social array? I think that you could also use the new json type for that too.
I'll try to assemble a quick demo of each option.
<!-- github-comment-id:1039633796 -->
@bwklein I am not, but I am also trying to figure out where I will need to make changes without effecting my forestry sites (too much if possible), since it is more efficient for me to change sites in VSC. I have a few client sites done in Hugo, and the sites I own are Pelican with very similar structure and logic. I guess I am struggling to translate how FM will work in recreating the functionality in forestry.io.
@bwklein I am not, but I am also trying to figure out where I will need to make changes without effecting my forestry sites (too much if possible), since it is more efficient for me to change sites in VSC. I have a few client sites done in Hugo, and the sites I own are Pelican with very similar structure and logic. I guess I am struggling to translate how FM will work in recreating the functionality in forestry.io.
<!-- github-comment-id:1039653050 -->
@apowell656 so yes I think there is some work yet to do for nested field groups within field groups. Looks like @estruyf is working on supporting this already. I wasn't able to get it to work yet in my demo site, but that might also be due to not getting the config structure correct myself.
I also would probably setup a data file or markdown files to manage 'author' information in a single spot and then in a post front matter I would only use the author's id string. You can use that ID to then pull the necessary information from the markdown/data file for rendering into the template. This is more DRY than adding this information to every post/page/section, etc.
There are some other things like this going on in this site. You could do the same thing with author information in data files, but going with Markdown content pages was better for our use.
@apowell656 so yes I think there is some work yet to do for nested field groups within field groups. Looks like @estruyf is working on supporting this already. I wasn't able to get it to work yet in my demo site, but that might also be due to not getting the config structure correct myself.
I also would probably setup a data file or markdown files to manage 'author' information in a single spot and then in a post front matter I would only use the author's id string. You can use that ID to then pull the necessary information from the markdown/data file for rendering into the template. This is more DRY than adding this information to every post/page/section, etc.
I have an example of this in a new 'blog' section that I am building for 'The Good Docs Project'.
Development Branch for the Blog - https://github.com/thegooddocsproject/website-hugo/tree/blog-test
Here is an example Author markdown file. We did this so authors would have their own page on the site with additional information they want to share. https://github.com/thegooddocsproject/website-hugo/blob/blog-test/content/en/authors/bryan_klein.md with the associated author page preview https://deploy-preview-68--gdp-hugo.netlify.app/authors/bryan_klein/
Here is an example of where the author ID (the author's filename), is used in the front matter of a post.
https://github.com/thegooddocsproject/website-hugo/blob/blog-test/content/en/blog/sixth.md
You could do that multiple author selection field with a 'Choices' field, using an id/title pair. Here is the preview of that post: https://deploy-preview-68--gdp-hugo.netlify.app/blog/sixth/
```
{
"title": "Author(s)",
"name": "author",
"type": "choice",
"choices": [
{ "id": "bryan_klein", "title": "Bryan Klein" },
{ "id": "ryan_macklin", "title": "Ryan Macklin" }
],
"multiple": true
}
```
Here is the single template for a blog post that uses a couple of partials to render information related to the authors. https://github.com/thegooddocsproject/website-hugo/blob/blog-test/layouts/blog/single.html
Here is the partial where the list of author names and links to their pages are rendered https://github.com/thegooddocsproject/website-hugo/blob/blog-test/layouts/partials/_shared/author-info.html
Here is another partial where the blurb at the bottom of the post about the author is rendered. https://github.com/thegooddocsproject/website-hugo/blob/blog-test/layouts/partials/single-partials/author-follow.html
There are some other things like this going on in this site. You could do the same thing with author information in data files, but going with Markdown content pages was better for our use.
<!-- github-comment-id:1039676128 -->
The support for 'fields' field is kind of working, I now see it in the UI and can edit the 'Title' text. But I am having some trouble with the image part. It opens up the media viewer and I can click the 'plus' icon to insert, but then the UI on the left flashes, closes the block I was editing and the image path is not added to the 'image' field. See this happen in the video below.
image_insert.mp4
If I add the path to an 'image' field directly in the file front matter, I get an error about how the image cannot be loaded.
Image field should now be supported, next up are the taxonomy fields (tags, categories, custom).
> The support for 'fields' field is kind of working, I now see it in the UI and can edit the 'Title' text. But I am having some trouble with the image part. It opens up the media viewer and I can click the 'plus' icon to insert, but then the UI on the left flashes, closes the block I was editing and the image path is not added to the 'image' field. See this happen in the video below.
>
> image_insert.mp4
> If I add the path to an 'image' field directly in the file front matter, I get an error about how the image cannot be loaded.
Image field should now be supported, next up are the taxonomy fields (tags, categories, custom).
<!-- github-comment-id:1039691272 -->
Taxonomy field support has been added. Feel free to test it out and let me know which problems you might experience.
Taxonomy field support has been added. Feel free to test it out and let me know which problems you might experience.
<!-- github-comment-id:1039706825 -->
@estruyf what is the best structure for repeated field sets like in 'social' array of this example. Should 'socal' be a block type with a field group or something else?
authors:
- name: Chris Smith
image: /assets/img/chris.jpg
tagline: I want some burgers and fries!
details: 'A self-proclaimed “pop-culture expert,” Chris excels at relating any conversation to some obscure reference. He can also rattle off a number of useless football statistics, especially i›f it’s NC State related. Chris lives with his beautiful wife, Christie, his talented daughter, Helena, and their lovable dogs, Ambrose and Cerberus.'
social:
- name: Twitter
logo: fab fa-twitter
url: 'https://twitter.com/Chim77Richalds'
- name: Instagram
logo: fab fa-instagram
url: 'https://www.instagram.com/eatin__vegan/'
I'll test it... thank you!
@estruyf what is the best structure for repeated field sets like in 'social' array of this example. Should 'socal' be a block type with a field group or something else?
```
authors:
- name: Chris Smith
image: /assets/img/chris.jpg
tagline: I want some burgers and fries!
details: 'A self-proclaimed “pop-culture expert,” Chris excels at relating any conversation to some obscure reference. He can also rattle off a number of useless football statistics, especially i›f it’s NC State related. Chris lives with his beautiful wife, Christie, his talented daughter, Helena, and their lovable dogs, Ambrose and Cerberus.'
social:
- name: Twitter
logo: fab fa-twitter
url: 'https://twitter.com/Chim77Richalds'
- name: Instagram
logo: fab fa-instagram
url: 'https://www.instagram.com/eatin__vegan/'
```
<!-- github-comment-id:1039712076 -->
Image field should now be supported, next up are the taxonomy fields (tags, categories, custom).
The path to the image is added to the front matter data, but the image isn't loading.
@estruyf
> Image field should now be supported, next up are the taxonomy fields (tags, categories, custom).
The path to the image is added to the front matter data, but the image isn't loading.

<!-- github-comment-id:1039714020 -->
@estruyf what is the best structure for repeated field sets like in 'social' array of this example. Should 'socal' be a block type with a field group or something else?
How I see it, is that authors is of type block, linked with a field group type of author.
author itself contains a block field social, linked to a social field group.
Haven't tested it yet to that extent.
> I'll test it... thank you!
>
> @estruyf what is the best structure for repeated field sets like in 'social' array of this example. Should 'socal' be a block type with a field group or something else?
How I see it, is that `authors` is of type block, linked with a field group type of `author`.
`author` itself contains a block field `social`, linked to a `social` field group.
Haven't tested it yet to that extent.
<!-- github-comment-id:1039714461 -->
Ok, that's what I tried, but with a single block field it wouldn't let me add an array of that one block type. Let me try again now since you have worked on taxonomies and those are working well for me.
Ok, that's what I tried, but with a single block field it wouldn't let me add an array of that one block type. Let me try again now since you have worked on taxonomies and those are working well for me.
<!-- github-comment-id:1039721811 -->
Image field should now be supported, next up are the taxonomy fields (tags, categories, custom).
The path to the image is added to the front matter data, but the image isn't loading.
Fix for this is coming up.
> @estruyf
>
> > Image field should now be supported, next up are the taxonomy fields (tags, categories, custom).
>
> The path to the image is added to the front matter data, but the image isn't loading.
>
> 
Fix for this is coming up.
<!-- github-comment-id:1039732999 -->
I tried the structure that you mentioned and I am getting an unexpected output from that in front matter data.
```
authors:
- authors:
name: Bryan
social:
- authors: {}
social:
name: Twitter
fieldGroup: social
fieldGroup: author
```
Authors field of type 'block' linked to 'author' field group:
https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L230
Author field group specification, with a 'social' field of type 'block' with a link to 'social' field group.
https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L291
Social field group with a single 'service name' field.
https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L309
<!-- github-comment-id:1039744004 -->
Trying it as well, the output looks ok, but the experience is not great. This will require some enhancements.
> I tried the structure that you mentioned and I am getting an unexpected output from that in front matter data.
>
> ```
> authors:
> - authors:
> name: Bryan
> social:
> - authors: {}
> social:
> name: Twitter
> fieldGroup: social
> fieldGroup: author
> ```
>
> Authors field of type 'block' linked to 'author' field group: [gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L230](https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L230)
>
> Author field group specification, with a 'social' field of type 'block' with a link to 'social' field group. [gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L291](https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L291)
>
> Social field group with a single 'service name' field. [gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L309](https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L309)
Trying it as well, the output looks ok, but the experience is not great. This will require some enhancements.
<!-- github-comment-id:1039763499 -->
I have empty objects from higher level entities down in the lower level.
> the output looks ok
How are you getting the output to look right?
I have empty objects from higher level entities down in the lower level.
<!-- github-comment-id:1039777794 -->
@estruyf ahh, so field groups will get me closer to what I need along with the block field. I will hopefully have time to test it tomorrow.
@bwklein the author information I use appears on the homepage only once at the bottom.
@estruyf ahh, so field groups will get me closer to what I need along with the block field. I will hopefully have time to test it tomorrow.
@bwklein the author information I use appears on the [homepage](https://chrisandandreshow.com) only once at the bottom.
<!-- github-comment-id:1040271038 -->
Added a couple of fixes + you can now save/cancel the data.
Save: closes the form
Cancel: resets the data back before you started editing
Added a couple of fixes + you can now save/cancel the data.
Save: closes the form
Cancel: resets the data back before you started editing
<img width="399" alt="Screenshot 2022-02-15 at 07 40 03" src="https://user-images.githubusercontent.com/2900833/154096396-faf6962d-7aa4-4103-b366-1a80e534d93d.png">
<!-- github-comment-id:1040428806 -->
Added a couple of fixes + you can now save/cancel the data.
Save: closes the form Cancel: resets the data back before you started editing
@estruyf it is working perfectly!!!! Thank you!
> Added a couple of fixes + you can now save/cancel the data.
>
> Save: closes the form Cancel: resets the data back before you started editing
@estruyf it is working perfectly!!!! Thank you!

<!-- github-comment-id:1040475548 -->
Can labelField be used for the text in the records list, with the name of the record type (author & social) being used as a fallback if labelField is not used?
Can `labelField` be used for the text in the records list, with the name of the record type (author & social) being used as a fallback if labelField is not used?
<!-- github-comment-id:1040488769 -->
At this point, I don't think this is a blocker anymore, I can start work on the 2 projects requiring Field Groups in frontmatter. Thank you for getting this done so quickly.
At this point, I don't think this is a blocker anymore, I can start work on the 2 projects requiring Field Groups in frontmatter. Thank you for getting this done so quickly.
<!-- github-comment-id:1040507030 -->
I am thinking of adding this into your examples for a Hugo site.
I've updated my demo project with support for this. https://gitlab.com/zivbk1/hugostarter
I am thinking of adding this into your examples for a Hugo site.
<!-- github-comment-id:1040521492 -->
Label field support added 🚀

<!-- github-comment-id:1040687053 -->
@estruyf , one word amazing! I have been able to rebuild my troublesome about-section. A couple of things, is it possible to add an image field to fieldGroup and add a default string to a field?
When I select an image the dialog closes or when I look at the current about-section, the image is not found (that could be because it is not in the media folder).
A workaround for the default string is to create a string with one choice and I tried to use a placeholder without success.
@estruyf , one word amazing! I have been able to rebuild my troublesome about-section. A couple of things, is it possible to add an image field to fieldGroup and add a default string to a field?
When I select an image the dialog closes or when I look at the current about-section, the image is not found (that could be because it is not in the media folder).
A workaround for the default string is to create a string with one choice and I tried to use a placeholder without success.
<!-- github-comment-id:1042862808 -->
Don't think I completely follow what you are asking for. Could you share some more details or screenshots?
About the default value, this is something the image field is not yet supporting. I'll create an issue for it to get that in as well.
@apowell656 thanks! 🙏
Don't think I completely follow what you are asking for. Could you share some more details or screenshots?
About the default value, this is something the image field is not yet supporting. I'll create an issue for it to get that in as well.
<!-- github-comment-id:1043214745 -->
@estruyf my image issue may be related to an earlier comment dealing with images, but I have 'the image cannot be loaded' error for images referenced in the fieldGroup.
I believe my issue may is because they are in the asset folder of the theme and not in the media folder, but when I try to use an image from the media folder, the dialog box closes and just shows the rest of the block section. So I cannot test to see if an image works in the fieldGroup.
I am stuck in meetings until later tonight, so I won't be able to test until then, and thanks for adding the default value support.
@estruyf my image issue may be related to an earlier comment dealing with images, but I have 'the image cannot be loaded' error for images referenced in the fieldGroup.
I believe my issue may is because they are in the asset folder of the theme and not in the media folder, but when I try to use an image from the media folder, the dialog box closes and just shows the rest of the block section. So I cannot test to see if an image works in the fieldGroup.
I am stuck in meetings until later tonight, so I won't be able to test until then, and thanks for adding the default value support.
<!-- github-comment-id:1043377943 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
With 'Page Sections' or 'Blocks' in front matter data, there needs to be a way to define section/block templates and then manage a list/array of them in front matter.
To add, remove, change order of elements in the list and edit the front matter data in the block elements.
For an example see: https://forestry.io/blog/sawmill-layout-composer-for-hugo-and-forestry/#hugo-example
For a working example of this system in action see:
Website - https://psrfcu.org/
Repo - https://gitlab.com/psrfcu/psrfcu-2019/-/blob/master/content/_index.md
Thanks @bwklein for the suggestion! The repo link you shared ends up on a 404 page. Would you be able to check the URL again? Once I can see how you are using it, I can understand the logic a bit better.
Note, that with content files like this, there usually isn't any {{.Content}} in the body of the markdown file. Everything is defined in front matter variables to populate variables in the partials used to render the data into the page block.
It makes the site more like a traditional CMS where the information for the design components (blocks) is stored in the front matter data model and not all in markdown/html within the body of the content file.
Thank you for providing a sample! This makes it clear to me. As of what I can see this is specific to Forestry. I like the idea, but also think it's a bit abusing the front matter. Shortcodes would be a cleaner way and probably makes it better suitable for other SSGs.
Just to understand a couple of things. These page sections, where do you define these? I assume these are custom things you need to configure before they will be able to be used. Is that true?
Yes, essentially you make design elements or blocks in your partials directory. Then you have a layout type that reads through the front matter and for each 'page_section' it calls the appropriate 'block' and passes the data from that page_section array element into the partial. All of that would need to be setup first, to define what inputs are required for that block partial.
You also need to define the set of inputs for a particular block and use that for editing the data in the array of page_sections/blocks. In Forestry this is done with their Front Matter Templates, in Cloud Cannon this is done with array structures, see the attached file starting at line 80 for the Cloud Cannon array structures that match with the file I pasted above.
cloudcannon.toml.zip
This approach works great in the situation where you want to reuse design elements on different pages and the editor can move them around and fill in the required information for each block as they 'assemble' the page from top to bottom.
In the site I posted the file for above, there are 19 different blocks that someone could build a page out of.
You are correct shortcodes could work too, but would make it difficult to reopen the editor for the block to make changes to an existing shortcode, unless you had a parser that would read the shortcode string and populate the snippet insertion UI with the values from the shortcode string. It seems like it would be a bit easier to define an array field type and a mini 'content type' for each 'block' that could be added into the array.
I think of shortcodes as a simple way to insert a smaller design element (figure, table, video, tweet) into the body of a larger Markdown file. Where this 'blocks' system is a way of composing entire pages from top to bottom, where each layer in the stack has a specific set of inputs to that specific layer.
One thing to note is that shortcodes will NOT work within the content of a layer field. So you will see in my example file code that there are 'content_markdown' fields for some blocks. If you put a shortcode in there it won't render the shortcode result into the page, there will just be a shortcode string in the content of that block. You can 'markdownify' the content_markdown into HTML, but the shortcodes are ignored. There is an existing Hugo project issue to resolve this and allow for shortcodes in frontmatter text to be rendered.
@estruyf this has become a blocker for me. I can't use it on sites where I have arrays of data in Front Matter. Do you have any suggestions for a workaround, or ideas on how to implement this in FM?
@zivbk1 added it to the board for the next release. At the moment there is no workaround for it. Think it is best to start with #197
@zivbk1 does #197 get this supported as well? Or are there missing pieces still?
I think it is closer, but the missing piece is a field type in a template where you can choose from a set of defined data structures to add them into an array in the front matter. Do the examples above help or should I setup a more simple example/test for this feature?
My two cents - I use Forestry Blocks for a two client sites (Hugo) and one personal(Pelican) to allow the users a familiar front end to contribute content and build pages. Their "Blocks" feature is a game changer for changing pages. I thought about asking for this feature also, but I could not even think of how it would take advantage of the existing FM UI without a modal/dialog box and my Pelican sites don't use shortcodes, so I did not propose them.
If it can happen that would be cool if not I might just make project level snippets.
Project level snippets is going to be the next major improvement for Front Matter, this is certain
There needs to be a benefit of using these over what VS Code provides by default. We're thinking about:
One thing that would make it great, is to have a way to get easily update the snippets that are already defined in the content.
About the list field, I've been thinking of using the same data field schema (JSON schema) which is used in the new data view.
@estruyf yes that are nice features.
i am still not familiar with json and the scheme technics. Hopefully this project may clarify some aspects of using json and json schemes.
i am thinking of the Specifications that are announced on the Specification documents on the JSON Schema org.
Versioning and looking forward is nice, but if you are out of date it may be getting complicated to be up to date. telling it from a perspective of an unemployed who stucks learning after some issues.
Which schema is the right one? Should this be hardcoded somehow, or would/should be let over to the developer?
i am getting overhelmed trying to find ressources for a clear explanation for json schemes, it looks realy fluent. but, it is a nice solution, but for me not clear enough right now.
also yaml is explaining itself as a clear solution, binding both together with a clean solution might be helpfull.
yaml to json schema and json data, and also json schema and json data to yaml? decide :-) well i need some vacation :-)
@wemasoe the version of the JSON schema does only matter when you are going to create really complicated data types. If you only need a couple of data fields, the schema is "pretty" easy to understand. There is always a trade-off with each road picked or decision.
The same goes for YAML, it is easy to understand, but this is just the data representation. When you would create a YAML schema to define the data structure, it would also mean you need to think it through a bit and do some trial and error.
Another reason why JSON Schema has been taken is that VS Code its settings are JSON driven and this keeps it all aligned.
Future
If we get more contributors on board, or if I manage to make more time available, one of the ideas that are on the backlog is to create a content type/settings dashboard (#129). This could become a drag and drop kind functionality to create data types and content types. Which eventually might make it easier for any that is not familiar with it.
step by step, everything is going to be good
i have to say the vscode extension Front Matter is a nice project, again, again, again.
@estruyf does this help clarify the need or should I provide a better example?
I have begun setting up a Hugo starter that uses this method of page building. https://gitlab.com/zivbk1/hugostarter
You can see in that project that there are already 2 'blocks' that a person can use to build a page.
https://gitlab.com/zivbk1/hugostarter/-/tree/main/layouts/partials/blocks
You can see here the code that is used to take the frontmatter of a page and call the correct block partial into place from top to bottom of the page. https://gitlab.com/zivbk1/hugostarter/-/blob/main/layouts/_default/page.html
Finally, you can see in this file where both blocks are called into the page from the
page_sectionsarray.https://gitlab.com/zivbk1/hugostarter/-/blob/main/content/_index.md
Here is an example of the definition of that 'page' content type. Where there are two choices (for brevity) that can be 'added' into the
page_sectionsfront matter array of a 'page' content type.In this context, any 'icon' defined would be pulled from something like https://fonts.google.com/icons?selected=Material+Icons
After building that data structure, it seems like it would be nice to define choice arrays somewhere else in the config file that can be reused by referring to them by name. Like a background color and text color set of options that can be used in different choice fields to keep things DRY.
To add to my comment above. It would be nice to see the list of page sections in the UI in an expandable accordion or something like that, where the order of the array can be changed and then edited in the expanded accordion space below the heading or maybe an editing modal that opens for that specific data item in the array. It would also be good to identify what field in the block you want to show in the stacked list of page_sections, similar to "labelField" in the data file definition. This is where it would be nice to just show the icon and then the text for the "labelField".
A lot of what I am talking about seems very similar to how the data file editor works now. Maybe use a similar UI with the stack of sections similar to the array of data items in a data file, and a very similar order and editing UI for those sections.
Still work in progress, but this is what the new collection data field looks like:
Style changes + some fixes have been added. Just committed the first version of the new control.
In order to use it, you'll need to define the field in your content type as follows:
In the
frontMatter.data.types, you can define your data type to use for the collection.Can "dataType": "page_sections2" be set up as a list of data types that can be added into the Record set?
In most use cases there would be different 'blocks' or data structures that would be added to the list of records. Where in your example 'Record 1' would be one data type, 'Record 2' would be another, and so on.
Also, would there be an ability to reorder the list, to put Record 3 above Record 1?
This is some example frontmatter that I would want to make work.
Where the first 'block' or record in the array has a data structure that includes the fields,
block,heading_markdown,background_choice,text_choiceand a second data type that only contains the fieldblockset to the default value of 'content'.If it can be defined in a JSON schema, it will be possible, but having different data types, loaded in the data collection field is not “yet” possible.
Technically it’s possible, I first focused on the main collection functionality and getting the fields right
Been thinking, so if the dataType can contain multiple data types, we could for instance show first a dropdown that allows you to select the type. Once you choose the type, it will show the additional data type's fields.
In order for this to work, we need to have an
idfield that corresponds to the data type you picked. Otherwise, it would be guessing which one you took. In your case, it isblock, could we change it totype? That way it would be a bit more generic.FWIW - In my forestry setups I use
templateand it works, so I don't think using type will be an issue. A generic term is probably the best way to go.Thanks for the feedback! Have been coding during my flight. Will commit the changes later.
Changed it to data blocks and block types. When configuring, you can select one type or many. Once you pick many, you'll need select the type to use and add the data.
Hope it will make sense.
This makes perfect sense to me.
The field will need to be configured as follows:
or
I'm going to try it today! 🙂
I'm trying it out-ish, but I think I need a primer. :-(
@apowell656 you will need two things:
frontMatter.data.typessettingsblockfield definedfrontMatter.data.types - setting
frontMatter.taxonomy.contentTypes - setting
@estruyf that put me on the right track. I looked into the documentation to get me across the finish line, but I think I am missing something. Do I need to create a data.type for each "block"/template? I tried changing the template to block in the page_sections with the same result.
@apowell656 yes, you'll have to specify what your block looks like, otherwise, it is a bit hard to render the form.
To compare it to Forestry:
I am getting an "Error loading field" error when trying to use the 'choice' field type in a block the data type definition.
Also, is it possible to use the "default" and "hidden" properties for a particular field?
For example, to always set
blockType: heroin a page_section block.I don't want the editor to change that field and break the page.
NOTE: I get "Error loading field" now if I add these.
@zivbk1 that is because it is a JSON schema and the
typesneed to be valid JSON known types:string, number, boolean, object, array. Custom types are not "yet" supported. It is doable to create custom types, but it means that there need to be custom renderers created for each new type. We probably need image and DateTime support as well.In case of the choices, you can use the following:
It might be good to not show the 'blockType' field in a page_section at all. I can't think of a use case where someone would want to edit that. If you want to change the blockType, then just add another block to the list of the correct type and delete the current one that is the wrong type.
I was just about to ask for that. 😄
Basically, anything you can do in the frontmatter UI, you could do within a block editor. Same field types, UI and functions.
Yes, this is supported, but you should not be doing it for the
blockTypefield, as that is automatically done by the extension.So, once a block has been created, you would only be able to move it or delete it?
Okay, I like my tests. Final question is it possible to nest an array? I have a template that has nested paragraphs (about-section) I am mentally halfway paying attention D@&n Super Bowl.
That is indeed what is needed. Also thinking about another option to extend the
fieldfield type. Right now it supports to only specified sub-fields, but what if we extend the field to allow field-bundle choices.Maybe this
blockfield, would better become acollectionfield, like how I initially had it in mind. As it allows you to reuse the data types from your data files/folders.The
blockfield, becomes a field type that allows you to do the same as what is defined above, but instead of specifying a data type, you specify afield block.field blockwould be a new setting, that comes with an ID and fields (all the fields from Front Matter are supported).This might be the best option after all. I might have been overthinking it due to the discussion we had about the file data/folders previously.
I actually love this new direction and it is closer to what I originally had in mind too.
I really just want a way to define 'blocks' (a configured selection of fields) and then have a way of picking from the defined set of blocks and adding them into an array ('page_sections' as an example of the array/collection name).
Once in the array, I can edit, move its position in the collection and delete them from the collection.
Also, it would be nice to specify a field in the
field blockto use as the text for the item in the list of blocks that have been added to the array. So the 'Title' of thefield_blockmight be 'Hero Banner' as the label for selecting the correct block from the list. Then there is a 'heading' field in theblockthat you would like to see in the label for the block in the collection.This way you can determine which 'hero' in the
page_sectionscollection is the one that has the text you want to edit.Yes, you can edit the contents of the block, change the order in the collection and delete it. I just don't want to be able to modify the block identification field (whatever it is called). Because that field is used to determine the 'field_block' template to use and determine the Hugo partial to render that section in the page. All of the other fields in the block are editable.
All - would anyone be willing to share a sample of usage?
Here is a super basic demo. Where the main index page uses blocks.
https://gitlab.com/zivbk1/hugostarter
@apowell656 @zivbk1 the
blockfield will now be thejsonfield.In the example of @zivbk1 - https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L55-63
You'll have to change
typetojson, andblockTypetodataType.Currently, the new
blockfield is in development.@estruyf thank you. I'll update this demo project when blocks are ready. What use case do you anticipate for the json type?
@estruyf and @zivbk1 thanks for links. I have validated my JSON to use nested content (my fields without nested content are working well), but the result is the error
Error loading field1. The documentation is not fleshed out well enough to explain if I can do this fordata.types` is that the case.Just there in case you want to reuse the data types you already have defined. As it was already developed, I didn't want to remove it.
This has probably to do with an invalid JSON schema. Once the new
blockfield is ready, I hope it will make it easier.Also, for some UI/UX feedback. The gray input fields and the gray text on the buttons made me think at first that they we 'inactive' or 'read-only'. I would make the inputs have a gray border only and use white text for the buttons.
@zivbk1 working first on the functionality 😁
Ok, think the first version of the
blocktype is ready to be tested.Configuration
Once you did this configuration, it will render a similar experience to the
JSONdata collection field, but with the default field like you are used to.It is working!!! https://gitlab.com/zivbk1/hugostarter/-/commit/ee9eb4bf1087d88d0f187cfcaf1d355be9dea9fd
I think you can remove the words 'your' and 'value' from the selection field placeholder text.
Update coming in to fix the background colors of the inputs + placeholders
I have added a 'Kitchen Sink' field group ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L189 ) to test all of the field types and I am having some trouble with two of the types. This is the 'content' file for the test ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/content/_index.md ).
'custom taxonomy' - 'feelings' ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L259 ) which shows a list of the feelings in the UI ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L215 ), but when I pick one it doesn't save it to the 'feeling' field in the file's front matter. It flashes for a moment and then nothing is selected or added to the file.
'fields' - 'photo' ( https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L220 ) which doesn't show up in the UI at all.
The support for 'fields' field is kind of working, I now see it in the UI and can edit the 'Title' text. But I am having some trouble with the image part. It opens up the media viewer and I can click the 'plus' icon to insert, but then the UI on the left flashes, closes the block I was editing and the image path is not added to the 'image' field. See this happen in the video below.
https://user-images.githubusercontent.com/12104446/153953117-5af9d536-85ea-4e65-a209-bb91517ea639.mp4
If I add the path to an 'image' field directly in the file front matter, I get an error about how the image cannot be loaded.
@apowell656
Why not just make that a single field that you can write markdown in and let the processor turn that into paragraphs in HTML for you?
@bwklein that sounds like a solve. Honestly, did not think of that and as I am typing I realize the oversight ;-).
@apowell656 one thing to be careful of in Hugo (if you are using it) is that currently shortcodes will not work in front matter content like that. There is an old issue in the Hugo project about it.
@apowell656 check this example out...
Source: https://gitlab.com/zivbk1/hugostarter/-/blob/main/content/_index.md#L19
Block Partial: https://gitlab.com/zivbk1/hugostarter/-/blob/main/layouts/partials/blocks/block-all.html#L9
@bwklein I think I may still have the same problem for other sections of my template for example:
Your proposal solves the
paragraphssection, but having a true repeatable field (example:authors) will be a problem, unless I break everything down into smaller components which is contradicting to DRY IMO.@apowell656 Are you using field groups for your social array? I think that you could also use the new json type for that too.
I'll try to assemble a quick demo of each option.
@bwklein I am not, but I am also trying to figure out where I will need to make changes without effecting my forestry sites (too much if possible), since it is more efficient for me to change sites in VSC. I have a few client sites done in Hugo, and the sites I own are Pelican with very similar structure and logic. I guess I am struggling to translate how FM will work in recreating the functionality in forestry.io.
@apowell656 so yes I think there is some work yet to do for nested field groups within field groups. Looks like @estruyf is working on supporting this already. I wasn't able to get it to work yet in my demo site, but that might also be due to not getting the config structure correct myself.
I also would probably setup a data file or markdown files to manage 'author' information in a single spot and then in a post front matter I would only use the author's id string. You can use that ID to then pull the necessary information from the markdown/data file for rendering into the template. This is more DRY than adding this information to every post/page/section, etc.
I have an example of this in a new 'blog' section that I am building for 'The Good Docs Project'.
Development Branch for the Blog - https://github.com/thegooddocsproject/website-hugo/tree/blog-test
Here is an example Author markdown file. We did this so authors would have their own page on the site with additional information they want to share. https://github.com/thegooddocsproject/website-hugo/blob/blog-test/content/en/authors/bryan_klein.md with the associated author page preview https://deploy-preview-68--gdp-hugo.netlify.app/authors/bryan_klein/
Here is an example of where the author ID (the author's filename), is used in the front matter of a post.
https://github.com/thegooddocsproject/website-hugo/blob/blog-test/content/en/blog/sixth.md
You could do that multiple author selection field with a 'Choices' field, using an id/title pair. Here is the preview of that post: https://deploy-preview-68--gdp-hugo.netlify.app/blog/sixth/
Here is the single template for a blog post that uses a couple of partials to render information related to the authors. https://github.com/thegooddocsproject/website-hugo/blob/blog-test/layouts/blog/single.html
Here is the partial where the list of author names and links to their pages are rendered https://github.com/thegooddocsproject/website-hugo/blob/blog-test/layouts/partials/_shared/author-info.html
Here is another partial where the blurb at the bottom of the post about the author is rendered. https://github.com/thegooddocsproject/website-hugo/blob/blog-test/layouts/partials/single-partials/author-follow.html
There are some other things like this going on in this site. You could do the same thing with author information in data files, but going with Markdown content pages was better for our use.
Image field should now be supported, next up are the taxonomy fields (tags, categories, custom).
Taxonomy field support has been added. Feel free to test it out and let me know which problems you might experience.
I'll test it... thank you!
@estruyf what is the best structure for repeated field sets like in 'social' array of this example. Should 'socal' be a block type with a field group or something else?
@estruyf
The path to the image is added to the front matter data, but the image isn't loading.
How I see it, is that
authorsis of type block, linked with a field group type ofauthor.authoritself contains a block fieldsocial, linked to asocialfield group.Haven't tested it yet to that extent.
Ok, that's what I tried, but with a single block field it wouldn't let me add an array of that one block type. Let me try again now since you have worked on taxonomies and those are working well for me.
Fix for this is coming up.
I tried the structure that you mentioned and I am getting an unexpected output from that in front matter data.
Authors field of type 'block' linked to 'author' field group:
https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L230
Author field group specification, with a 'social' field of type 'block' with a link to 'social' field group.
https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L291
Social field group with a single 'service name' field.
https://gitlab.com/zivbk1/hugostarter/-/blob/main/frontmatter.json#L309
Image preview is working now!!! 🎉
Trying it as well, the output looks ok, but the experience is not great. This will require some enhancements.
How are you getting the output to look right?
I have empty objects from higher level entities down in the lower level.
Took your example:
Content Type
Field Groups
As mentioned the UX needs to have some love in order to make it usable.
@estruyf ahh, so field groups will get me closer to what I need along with the block field. I will hopefully have time to test it tomorrow.
@bwklein the author information I use appears on the homepage only once at the bottom.
Added a couple of fixes + you can now save/cancel the data.
Save: closes the form
Cancel: resets the data back before you started editing
@estruyf it is working perfectly!!!! Thank you!
Can
labelFieldbe used for the text in the records list, with the name of the record type (author & social) being used as a fallback if labelField is not used?@zivbk1 can be done for sure!
At this point, I don't think this is a blocker anymore, I can start work on the 2 projects requiring Field Groups in frontmatter. Thank you for getting this done so quickly.
Great to hear! Let me know if there are things to optimize or if you find additional issues.
I've updated my demo project with support for this. https://gitlab.com/zivbk1/hugostarter
I am thinking of adding this into your examples for a Hugo site.
Label field support added 🚀
@estruyf , one word amazing! I have been able to rebuild my troublesome about-section. A couple of things, is it possible to add an image field to fieldGroup and add a default string to a field?
When I select an image the dialog closes or when I look at the current about-section, the image is not found (that could be because it is not in the media folder).
A workaround for the default string is to create a string with one choice and I tried to use a placeholder without success.
@apowell656 thanks! 🙏
Don't think I completely follow what you are asking for. Could you share some more details or screenshots?
About the default value, this is something the image field is not yet supporting. I'll create an issue for it to get that in as well.
The default values enhancement #255 is now included.
@estruyf my image issue may be related to an earlier comment dealing with images, but I have 'the image cannot be loaded' error for images referenced in the fieldGroup.
I believe my issue may is because they are in the asset folder of the theme and not in the media folder, but when I try to use an image from the media folder, the dialog box closes and just shows the rest of the block section. So I cannot test to see if an image works in the fieldGroup.
I am stuck in meetings until later tonight, so I won't be able to test until then, and thanks for adding the default value support.
This is all working well for me now.
Thank you @zivbk1 to verify this.