{% comment %} Copyright (C) 2020 Google LLC. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.foobar2 {% endcomment %} {% comment %} This logic is trying to find the last portion of the path after the base url to match for the side nav. The page url should be in the form /foo/bar/. Sometimes pages also have a trailing .html like /foo/bar.html or a trailing /. We strip those off and split on the / separator (the split function handles the trailing / and ignores it) to find the base "/foo" and the "/bar" for the side nav to figure out the top and side nav location we are currently in. {% endcomment %} {% assign page_url = page.url | remove_first: "/" | remove: ".html" %} {% assign page_url_top = page_url | split: "/" | first | prepend: "/" %} {% assign page_url_rest = page_url | prepend: "/" | remove_first: page_url_top %} {% for i in site.nav %} {% if page_url_top == i.item.url %} {% assign topitem = i.item %} {% endif %} {% endfor %} {% if topitem.sidenav %} {% endif %}