"data".json (like index.json, but different template)

I have a section, call it “projects” where each project page has front-matter/sidebar information. I’d like to make a projects/data.json file that is a summary built off front matter data contained in all of pages of that project section.

I know how to make an index.json file for doing things like using Fuse to create searches, but that contains all pages in the entire site, and I’m already using index.json for searching. What I want is something specific to the projects section that contains different information than what I would put in index.json anyway. I also don’t want projects pages to be removed from index.json.

Any advice?

I’m not 100% sure about the solution I’m posting. I had figured out to use it just once, and forgot again. But, it can probably get you going.

In your config.toml:

[outputs]
	home = ["HTML", "DATA"]

[outputFormats.Data]
	mediaType = "application/json"
	baseName = "data"
	isPlainText = true

Edit the JSON in layouts/index.data.json.

That should do it.

1 Like

Just wanted to follow-up with a big thank you. Works across the entire site… will work on making it per-section.

2 Likes