{%- comment -%} Uses _data/versions.yml to scope out version history, conditionally preparing each expected version path, depending on whether it's a current index, old index, or a versioned non-index page. Display can be disabled using `versioning: false` in a page's frontmatter. {%- endcomment -%} {%- assign latest_qry = site.data.versions | where: "latest", "true" -%} {%- assign latest = latest_qry[0] -%} {%- assign name_strip = page.name | remove: ".html" -%} {%- assign name_split = name_strip | split: "-" -%} {%- assign path_split = page.path | split: "/" -%} {%- if page.url == "/" -%}{%- comment -%}site homepage{% endcomment %} {%- assign page_type = "latest-index" -%} {%- assign page_version = latest.slug -%} {%- else -%} {%- if name_split[0] == "index" -%}{%- comment -%}older index{% endcomment %} {%- assign page_type = "old-index" -%} {%- capture page_version -%}{{name_split[1]}}-{{name_split[2]}}{%- endcapture -%} {%- else -%} {%- if page.collection -%} {%- assign col = site.collections | where: "label", page.collection -%} {%- if col[0].type == "version" -%} {%- comment -%}A page in a versioned collection{% endcomment %} {%- assign page_type = "versioned" -%} {%- assign page_version = page.collection -%} {%- else -%} {%- assign page_type = "unversioned" -%} {%- endif -%} {%- else -%} {%- assign page_type = "unversioned" -%} {%- assign page_version = latest.slug -%} {%- endif -%} {%- endif -%} {%- endif %} {% assign page_vsn_qry = site.data.versions | where: "slug", page_version %} {% assign page_vsn_obj = page_vsn_qry[0] | default: latest %}