{% set page_url_parts = page.nb_url.split('/') %} {% set gh_ns = namespace(gh_nb_url='') %} {# Create a namespace to store the variable #} {% for page_url_part in page_url_parts %} {% if loop.index == page_url_parts | length %} {% set gh_ns.gh_nb_url = gh_ns.gh_nb_url + page_url_part %} {% endif %} {% endfor %}