{% set toc_ = page.toc %}
- {% if toc_ | first is defined %}
+ {% if toc_ | first is defined and "\x3ch1 id=" in page.content %}
{% set toc_ = (toc_ | first).children %}
{% endif %}
{% if toc_ | first is defined %}
diff --git a/src/partials/nav-item.html b/src/partials/nav-item.html
index 1a39b51dd..07f6eee0c 100644
--- a/src/partials/nav-item.html
+++ b/src/partials/nav-item.html
@@ -71,7 +71,7 @@
type="checkbox" id="toc" />
- {% if toc_ | first is defined %}
+ {% if toc_ | first is defined and "\x3ch1 id=" in page.content %}
{% set toc_ = (toc_ | first).children %}
{% endif %}