{{- $ := index . "$" -}}
{{- $filename := .filename -}}

{{- $url := $filename -}}
{{- $pathParts := split ($.RelPermalink | strings.TrimPrefix "/" | strings.TrimSuffix "/") "/" -}}
{{- range $pathParts -}}
    {{- with . -}}
        {{- $url = printf `../%s` $url -}}
    {{- end -}}
{{- end -}}

{{- return $url -}}
