{% assign url_parts = page.url | split: "/" %} {% if url_parts.size > 0 %} {% assign last_url_part = url_parts | last %} {% comment %} Does the URL contain a filename, and is it an index.html or not? {% endcomment %} {% if last_url_part contains ".html" %} {% assign url_has_filename = true %} {% if last_url_part == 'index.html' %} {% assign url_filename_is_index = true %} {% else %} {% assign url_filename_is_index = false %} {% endif %} {% else %} {% assign url_has_filename = false %} {% endif %} {% comment %} OpenSearchCon URLs require some special consideration, because it's a specialization of the /events URL which is itself a child of Community; te OpenSearchCon menu is NOT a child of Community. {% endcomment %} {% if page.url contains "opensearchcon" %} {% assign is_conference_page = true %} {% else %} {% assign is_conference_page = false %} {% endif %} {% if is_conference_page %} {% comment %} If the page is a confernce page and it has a filename then its the penultimate path component that has the child menu item of the OpenSearchCon that needs to be marked as in-category. If there's no filename then reference the ultimate path component. Unless the filename is opensearchcon2023-cfp, because it's a one off that is not within the /events/opensearchcon/... structure. {% endcomment %} {% if url_has_filename %} {% unless page.url contains 'opensearchcon2023-cfp' %} {% assign url_fragment_index = url_parts | size | minus: 2 %} {% assign url_fragment = url_parts[url_fragment_index] %} {% else %} {% assign url_fragment = 'opensearchcon2023-cfp' %} {% endunless %} {% else %} {% assign url_fragment = last_url_part %} {% endif %} {% else %} {% comment %} If the page is NOT a conference page, the URL has a filename, and the filename is NOT index.html then refer to the filename without the .html extension. If the filename is index.html then refer to the penultimate path component. If there is not filename then refer to the ultimate path component. {% endcomment %} {% if url_has_filename %} {% unless url_filename_is_index %} {% assign url_fragment = last_url_part | replace: '.html', '' %} {% else %} {% assign url_fragment_index = url_parts | size | minus: 2 %} {% assign url_fragment = url_parts[url_fragment_index] %} {% endunless %} {% else %} {% assign url_fragment = last_url_part %} {% endif %} {% endif %} {% else %} {% assign url_fragment = '' %} {% endif %} {% if page.alert %} {% endif %} {% if site.data.alert.message %} {% endif %}