Custom Json file defaults to index.json

I have an index.json file that is used by the main site search. I am trying to create a secondary one for another search using output formats, but the JSON file defaults to the content in the index.json. I have copied the steps in the repo below to create the output format in my own theme.

Or what is the recommended way to create a secondary JSON index besides index.json?

Example

We’re going to generate two json files in the root of the public directory. One will be named index.json, the other will be named index_2.json.

Site configuration

[outputs]
home = ['HTML', 'JSON', 'JSON_2']

# We don't need to define the JSON output format. It's baked in.
[outputFormats.JSON_2]
baseName = 'index_2'
isPlainText = true
mediaType = 'application/json'

Layouts

layouts/
└── _default/
    β”œβ”€β”€ baseof.html
    β”œβ”€β”€ home.html
    β”œβ”€β”€ home.json_2.json  <-- generates public/index_2.json
    β”œβ”€β”€ home.json.json    <-- generates public/index.json
    β”œβ”€β”€ list.html
    └── single.html

Try it:

git clone --single-branch -b hugo-forum-topic-41808 https://github.com/jmooring/hugo-testing hugo-forum-topic-41808
cd hugo-forum-topic-41808
hugo server
1 Like

This might have been the issue.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.