diff --git a/layouts/partials/search.html b/layouts/partials/search.html
index b4408018c3..dee177b12d 100644
--- a/layouts/partials/search.html
+++ b/layouts/partials/search.html
@@ -5,11 +5,18 @@
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
{{- $pageBaseLang := replaceRE "([a-z]+).*" "${1}" .Page.Lang }}
- {{- $contentlangs := (union (slice | append .Site.Params.contentLang) (slice $pageBaseLang)) }}
+ {{- $contentlangs := (union (slice | append .Site.Params.additionalContentLanguage) (slice $pageBaseLang)) }}
{{- $quotedcontentlangs := slice }}
+ {{- $missingcontentlangs := slice }}
{{- range $contentlangs }}
- {{- $quotedcontentlangs = $quotedcontentlangs | append (printf "'%s'" .) }}
+ {{- $file := (printf "js/lunr.%s.min.js" .) }}
+ {{- if fileExists (printf "/static/%s" $file) }}
+ {{- $quotedcontentlangs = $quotedcontentlangs | append (printf "'%s'" .) }}
+ {{- else }}
+ {{- $missingcontentlangs = $missingcontentlangs | append . }}
+ {{- end }}
{{- end }}
+ {{- $contentlangs = $contentlangs | complement $missingcontentlangs }}
@@ -18,6 +25,7 @@
{{- range $contentlangs }}
-
+ {{- $file := (printf "js/lunr.%s.min.js" .) }}
+
{{- end }}
\ No newline at end of file