I would like to describe the data model in the files like I do now with content types, and then have a UI to edit the information in the files with a GUI.
Describe alternatives you've considered
I can edit the plain text files by hand, but what's the fun in that? Also, asking my editors to write JSON, YAML, TOML, etc. by hand is a bit much.
Additional context
Here is an example of a UI for the JSON content below.
**Is your feature request related to a problem? Please describe.**
I have a site where there are data files (JSON) used to drive the content in tables.
https://gohugo.io/templates/data-templates/
**Describe the solution you'd like**
I would like to describe the data model in the files like I do now with content types, and then have a UI to edit the information in the files with a GUI.
**Describe alternatives you've considered**
I can edit the plain text files by hand, but what's the fun in that? Also, asking my editors to write JSON, YAML, TOML, etc. by hand is a bit much.
**Additional context**
Here is an example of a UI for the JSON content below.

```
{
"columns": [
"Rating",
"Credit Score"
],
"rows": [
{
"cells": [
"A++",
"750+"
]
},
{
"cells": [
"A+",
"710 - 749"
]
},
{
"cells": [
"A",
"680 - 709"
]
},
{
"cells": [
"B",
"650 - 679 up to 80% LTV"
]
},
{
"cells": [
"C",
"620 - 649 up to 70% LTV"
]
}
]
}
```
<!-- github-sync-id:1063699096 -->
If there is data defined like this, the extension would render a new data tab and allow you to start editing the content.
Thinking about this one, what if you can define data types via the settings like:
```
{
"frontMatter.data.types": [
{
"name": "sponsors",
"file": "[workspace]/data/sponsors.json",
"schema": {
"title": "Sponsors",
"type": "object",
"required": [
"url",
"name",
"avatar"
],
"properties": {
"url": {
"type": "string",
"title": "URL"
},
"name": {
"type": "string",
"title": "Name"
},
"avatar": {
"type": "string",
"title": "Avatar"
}
}
}
}
]
}
```
If there is data defined like this, the extension would render a new `data` tab and allow you to start editing the content.
<!-- github-comment-id:1011198803 -->
@estruyf can you use wildcards to match all .json files in a particular folder?
Ex. [[workspace]]/data/tables/*.json
Matches all of these files in the tables folder...
@estruyf can you use wildcards to match all .json files in a particular folder?
Ex. `[[workspace]]/data/tables/*.json`
Matches all of these files in the tables folder...

<!-- github-comment-id:1012638046 -->
@estruyf can you use wildcards to match all .json files in a particular folder? Ex. [[workspace]]/data/tables/*.json
Matches all of these files in the tables folder...
For now, the data files would have to be defined in the settings. The definition is required to correctly render the form.
> @estruyf can you use wildcards to match all .json files in a particular folder? Ex. `[[workspace]]/data/tables/*.json`
>
> Matches all of these files in the tables folder...
For now, the data files would have to be defined in the settings. The definition is required to correctly render the form.
<!-- github-comment-id:1012860884 -->
@estruyf can you use wildcards to match all .json files in a particular folder? Ex. [[workspace]]/data/tables/*.json
Matches all of these files in the tables folder...
For now, the data files would have to be defined in the settings. The definition is required to correctly render the form.
Is it possible to define a structure for a data file once, then for each file in the folder indicate that the same structure is used. Repeating the whole structure in the configuration file for every file doesn't seem practical. I'm thinking of a way to say "Everything in this folder has this data structure."
> > @estruyf can you use wildcards to match all .json files in a particular folder? Ex. `[[workspace]]/data/tables/*.json`
> > Matches all of these files in the tables folder...
>
> For now, the data files would have to be defined in the settings. The definition is required to correctly render the form.
Is it possible to define a structure for a data file once, then for each file in the folder indicate that the same structure is used. Repeating the whole structure in the configuration file for every file doesn't seem practical. I'm thinking of a way to say "Everything in this folder has this data structure."
<!-- github-comment-id:1012963675 -->
That would mean files and types need to be split up. So you can have data types, to define the schema, and data files to specify the location and defined type ID.
That would mean files and types need to be split up. So you can have data types, to define the schema, and data files to specify the location and defined type ID.
<!-- github-comment-id:1012968340 -->
That would mean files and types need to be split up. So you can have data types, to define the schema, and data files to specify the location and defined type ID.
I like that idea. I could also see something like this working with a new Frontmatter field type that lets you define a set of defined data structures to pick from as a template, and add into an array. This concept would resolve the other issue I have for "blocks" (page_sections) stored in Front matter data. #176
> That would mean files and types need to be split up. So you can have data types, to define the schema, and data files to specify the location and defined type ID.
I like that idea. I could also see something like this working with a new Frontmatter field type that lets you define a set of defined data structures to pick from as a template, and add into an array. This concept would resolve the other issue I have for "blocks" (page_sections) stored in Front matter data. #176
<!-- github-comment-id:1012971769 -->
This allows you to at least use the configuration from above. I'll see what I can do for the type and file splitting.
Support for arrays has been added as well:

This allows you to at least use the configuration from above. I'll see what I can do for the `type` and `file` splitting.
<!-- github-comment-id:1012977301 -->
@zivbk1 data type support has been added. You can specify the schema on file level or on the type level.
On file level is easy when you'll use it a single time, when defining it on type level, you can reuse it.
```json
"frontMatter.data.files": [
{
"id": "test",
"file": "[[workspace]]/data/tests.json",
"labelField": "name",
"title": "Test",
"type": "genericContent"
}
],
"frontMatter.data.types": [
{
"id": "genericContent",
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"columns": {
"type": "array",
"items": { "type": "string" }
},
"rows": {
"type": "array",
"items": {
"type": "object",
"properties": {
"cells": {
"type": "array",
"items": { "type": "string" }
}
}
}
}
}
}
}
]
```
Hope this will make it easier for you.
<!-- github-comment-id:1013060652 -->
As discussed, I will add another setting frontMatter.data.folders. This setting will allow the extension to load all files from the folder and use the same data type
As discussed, I will add another setting `frontMatter.data.folders`. This setting will allow the extension to load all files from the folder and use the same data type
<!-- github-comment-id:1013291848 -->
i just want to reply to your help and give a feedback.
> @wemasoe easiest is to use a JSON to YAML converter.
>
> I converted the JSON object, to the following schema:
>
> ```json
> {
> "type": "object",
> "properties": {
> "entries": {
> "type": "array",
> "items": {
> "type": "object",
> "properties": {
> "title": {
> "type": "string"
> },
> "output": {
> "type": "string"
> },
> "type": {
> "type": "string"
> },
> "folderitems": {
> "type": "array",
> "items": {
> "type": "object",
> "properties": {
> "title": {
> "type": "string"
> },
> "url": {
> "type": "string"
> },
> "output": {
> "type": "string"
> },
> "type": {
> "type": "string"
> }
> }
> }
> }
> }
> }
> }
> },
> "additionalProperties": false,
> "required": [
> "entries"
> ]
> }
> ```
sorry to say the schema did not work.
i dont get any data entry in the data tab for this file.
```plantuml
Your other.yaml data items
No other.yaml data entries found
Create or modify your other.yaml data
Add new data
Entries
```
source file:
```yaml
entries:
- title: other
folders:
- title: Other Links
folderitems:
- title: Automated links bookmark
url: /bookmark_one.html
- title: Bookmark links
url: /bookmarks.html
- title: Some link bookmark
url: /other.html
```
when adding an entry old entries are gone.
```yaml
- entries:
- title: new title
output: output
type: type
folderitems:
- title: folderitem title
url: folder item url
output: folder item outpur
type: folderitem type
```
i just want to reply to your help and give a feedback.
<!-- github-comment-id:1014819067 -->
i have set it for a folder and can confirm it works. Although in "frontMatter.data.types": [ a file is set in the json schema "file": "[[workspace]]/data/data-entries.yml",
@estruyf thx a lot :-) JSON schema is not as easy as it seems. hope I will understand it sometime.
I understand, there are PROs and CONs on each schema/approach to use. I also validated Simple Schema, which seems "simple", but complicates objects IMO. That is why I picked JSON schema.
> @estruyf thx a lot :-) JSON schema is not as easy as it seems. hope I will understand it sometime.
I understand, there are PROs and CONs on each schema/approach to use. I also validated Simple Schema, which seems "simple", but complicates objects IMO. That is why I picked JSON schema.
<!-- github-comment-id:1017241927 -->
i have set it for a folder and can confirm it works. Although in "frontMatter.data.types": [ a file is set in the json schema "file": "[[workspace]]/data/data-entries.yml",
Documentation for these new settings is on its way (still needs to be written before releasing v6).
frontMatter.data.types: This only defines the object and its fields. There is no reference to any file or folder. It has two properties: id and schema
frontMatter.data.files: Defines how a single file needs to be handled. It can use a schema or an ID of the data type.
frontMatter.data.folders: Defines that all files from a folder need to be handled the same. It can use a schema or an ID of the data type.
In your case, you better define the type via the frontMatter.data.types setting and reuse it in the file and folders setting.
> i have set it for a folder and can confirm it works. Although in `"frontMatter.data.types": [` a file is set in the json schema ` "file": "[[workspace]]/data/data-entries.yml",`
Documentation for these new settings is on its way (still needs to be written before releasing v6).
- `frontMatter.data.types`: This only defines the object and its fields. There is no reference to any file or folder. It has two properties: `id` and `schema`
- `frontMatter.data.files`: Defines how a single file needs to be handled. It can use a schema or an ID of the data type.
- `frontMatter.data.folders`: Defines that all files from a folder need to be handled the same. It can use a schema or an ID of the data type.
In your case, you better define the type via the `frontMatter.data.types` setting and reuse it in the file and folders setting.
<!-- github-comment-id:1017248019 -->
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.
Is your feature request related to a problem? Please describe.
I have a site where there are data files (JSON) used to drive the content in tables.
https://gohugo.io/templates/data-templates/
Describe the solution you'd like
I would like to describe the data model in the files like I do now with content types, and then have a UI to edit the information in the files with a GUI.
Describe alternatives you've considered
I can edit the plain text files by hand, but what's the fun in that? Also, asking my editors to write JSON, YAML, TOML, etc. by hand is a bit much.
Additional context
Here is an example of a UI for the JSON content below.
Thinking about this one, what if you can define data types via the settings like:
If there is data defined like this, the extension would render a new
datatab and allow you to start editing the content.@zivbk1 been working on a new data dashboard.
What do you think?
Settings
The settings look as follows:
@estruyf can you use wildcards to match all .json files in a particular folder?
Ex.
[[workspace]]/data/tables/*.jsonMatches all of these files in the tables folder...
@estruyf how would I represent this data structure in
frontmatter.data.files?For now, the data files would have to be defined in the settings. The definition is required to correctly render the form.
More testing is required and for sure some styling is missing for lists. The schema for your data would looks as follows:
Is it possible to define a structure for a data file once, then for each file in the folder indicate that the same structure is used. Repeating the whole structure in the configuration file for every file doesn't seem practical. I'm thinking of a way to say "Everything in this folder has this data structure."
That would mean files and types need to be split up. So you can have data types, to define the schema, and data files to specify the location and defined type ID.
I like that idea. I could also see something like this working with a new Frontmatter field type that lets you define a set of defined data structures to pick from as a template, and add into an array. This concept would resolve the other issue I have for "blocks" (page_sections) stored in Front matter data. #176
Support for arrays has been added as well:
This allows you to at least use the configuration from above. I'll see what I can do for the
typeandfilesplitting.@zivbk1 data type support has been added. You can specify the schema on file level or on the type level.
On file level is easy when you'll use it a single time, when defining it on type level, you can reuse it.
Hope this will make it easier for you.
As discussed, I will add another setting
frontMatter.data.folders. This setting will allow the extension to load all files from the folder and use the same data type@estruyf realy nice project. i have tested the datafolder and can confrim it works.
Can you give me a hint for a good yaml to json scheme editor from an example yaml file?
i am thinking somtehing like a yaml file and to generate a schema from this example file?
or from a json example file
i have tried to generate a schema for this example file, and did not get it work.
@wemasoe easiest is to use a JSON to YAML converter.
I converted the JSON object, to the following schema:
sorry to say the schema did not work.
i dont get any data entry in the data tab for this file.
source file:
when adding an entry old entries are gone.
i just want to reply to your help and give a feedback.
Recreated it with the new sample you gave, and the following schema can create your data structure:
@estruyf thx a lot :-)
json schema is not as easy as it seems. hope i will understand it sometime.
i have set it for a folder and can confirm it works. Although in
"frontMatter.data.types": [a file is set in the json schema"file": "[[workspace]]/data/data-entries.yml",I understand, there are PROs and CONs on each schema/approach to use. I also validated Simple Schema, which seems "simple", but complicates objects IMO. That is why I picked JSON schema.
Documentation for these new settings is on its way (still needs to be written before releasing v6).
frontMatter.data.types: This only defines the object and its fields. There is no reference to any file or folder. It has two properties:idandschemafrontMatter.data.files: Defines how a single file needs to be handled. It can use a schema or an ID of the data type.frontMatter.data.folders: Defines that all files from a folder need to be handled the same. It can use a schema or an ID of the data type.In your case, you better define the type via the
frontMatter.data.typessetting and reuse it in the file and folders setting.