{{- $url := split .Permalink "/" -}}
{{- $page_version := index $url (sub (len $url) 4) -}}
{{- $group_slug := index $url (sub (len $url) 3) -}}
{{- $page_slug := index $url (sub (len $url) 2) -}}

{{- $versions_link := "" -}}
{{- if and (eq .Layout "docs") (eq $page_version .Site.Params.docs_version) -}}
  {{- $versions_link = printf "%s/%s/" $group_slug $page_slug -}}
{{- else if (eq .Layout "single") }}
  {{- $versions_link = printf "%s/" $page_slug -}}
{{- end }}

<li class="nav-item dropdown">
  <butto