I have two sections, Projects and Universities, where I want Hugo to generate JSON and HTML outputs.
The JSON for Universities works perfectly, but the JSON file for Projects is using the template for University. Is there a bug in Hugo’s lookup order or am I missing something?
Project Structure
├── config.toml
├── content
│ ├── about
│ ├── contact
│ ├── _index.md
│ ├── news
│ ├── projects
│ │ ├── project-1.md
│ │ └── project-2.md
│ ├── resources
│ └── universities
│ ├── a.md
│ ├── b.md
│ └── c.md
├── data
├── layouts
│ ├── _default
│ │ ├── baseof.html
│ │ ├── li.html
│ │ ├── list.html
│ │ ├── single.html
│ ├── index.html
│ ├── index.json
│ ├── news
│ │ └── single.html
│ ├── partials
│ ├── projects
│ │ ├── li.html
│ │ ├── list.html
│ │ ├── list.json
│ │ └── single.html
│ ├── resources
│ │ ├── li.html
│ │ └── single.html
│ ├── section
│ │ ├── about.html
│ │ └── contact.html
│ └── universities
│ └── list.json
├── resources
└── static
universities/list.json
{{ define "main" }}
[
{{ range $index, $e := .Data.Pages }}
{{ if $index }}, {{ end }}
{
"name": "{{ .Title }}",
"location" : "{{ .Params.Location }}",
"website" : "{{ .Params.Website }}",
"logo" : "{{ .Params.Logo }}"
}
{{ end }}
]
{{end}}
projects/list.json
{{ define "main" }}
[
{{ range $index, $e := .Data.Pages }}
{{ if $index }}, {{ end }}
{
"name": "{{ .Title }}",
"permalink": "{{ .Permalink }}",
"university" : "{{ .Params.university }}",
"date" : "{{ .Date.Format "02 Jan 06 15:04 -0700" }}",
"status" : "{{ .Params.status }}",
"description" : "{{ .Params.description }}",
"cats" : [
{{ range $index, $e := .Params.cats }}
{{ if $index }}, {{ end }}
"{{ .category }}"
{{ end }}
]
}
{{ end }}
]
{{end}}
Output of dist/projects/index.json
{
"data":
[
{
"name": "Project 2",
"location" : "<no value>",
"website" : "<no value>",
"logo" : "<no value>"
}
,
{
"name": "Project 1",
"location" : "<no value>",
"website" : "<no value>",
"logo" : "<no value>"
}
]
}