diff --git a/src/renderer/html_handlebars/search.rs b/src/renderer/html_handlebars/search.rs index d49772f8..1ee66a51 100644 --- a/src/renderer/html_handlebars/search.rs +++ b/src/renderer/html_handlebars/search.rs @@ -205,6 +205,10 @@ fn write_to_js(index: Index, search_config: &Search) -> Result { searchoptions, index, }; + + // By converting to serde_json::Value as an intermediary, we use a + // BTreeMap internally and can force a stable ordering of map keys. + let json_contents = serde_json::to_value(&json_contents)?; let json_contents = serde_json::to_string(&json_contents)?; Ok(format!("window.search = {};", json_contents))