diff --git a/layouts/partials/toc-id.html b/layouts/partials/toc-id.html
index 1e9a7eb4a2..efee626f09 100644
--- a/layouts/partials/toc-id.html
+++ b/layouts/partials/toc-id.html
@@ -25,8 +25,6 @@
{{- else if eq .Kind "term" }}
-
+ {{- $toc := trim (partial "toc.html" .) " \n\r\t" }}
+ {{- if and (not $toc) $toc_term }}
+ {{- $toc = printf "" }}
+ {{- end }}
+ {{- if and $toc $toc_term }}
+ {{- $toc = replaceRE "^()$" " ${1}" $toc }}
+ {{- $toc = replaceRE "([ \\t]*[\\s]*)$" (printf "%s${1}" $toc_term) $toc }}
+ {{- end }}
+{{ $toc | safeHTML }}
{{- else }}
{{- partial "toc.html" . }}
{{- end }}
\ No newline at end of file