{%- if page.collection == include.key -%} {%- for node in pages_list -%} {%- if node.parent == nil -%} {%- if page.parent == node.title or page.grand_parent == node.title -%} {%- assign first_level_url = node.url | absolute_url -%} {%- endif -%} {%- if node.has_children -%} {%- assign children_list = pages_list | where: "parent", node.title -%} {%- for child in children_list -%} {%- if child.has_children -%} {%- if page.url == child.url or page.parent == child.title and page.grand_parent == child.parent -%} {%- assign second_level_url = child.url | absolute_url -%} {%- endif -%} {%- endif -%} {%- endfor -%} {%- endif -%} {%- endif -%} {%- endfor -%} {% if page.has_children == true and page.has_toc != false %} {%- assign toc_list = pages_list | where: "parent", page.title | where: "grand_parent", page.parent -%} {%- endif -%} {%- endif -%}