{{ .Protocol }}://://
{{- if .URL -}}
{{- $page := . -}}
{{- $href := printf "/%s" .Protocol -}}
{{- $uriParts := split .URL "/" -}}
{{- $uriLast := $uriParts | last -}}
{{- $uriParts = $uriParts | pop -}}
{{- if eq $uriLast "" -}}
{{- $uriLast = $uriParts | last -}}
{{- $uriParts = $uriParts | pop -}}
{{- end -}}
{{- range $i, $part := $uriParts -}}
{{- if and (eq $page.Protocol "gopher") (eq $i 1) -}}
{{- $href = printf "%s/1" $href -}}
{{- $part = $part | trimLeftChar -}}
{{- if not (eq $part "") -}}
{{- $href = printf "%s/%s" $href $part -}}
/{{ $part }}
{{- end -}}
{{- else -}}
{{- $href = printf "%s/%s" $href . -}}
{{- if ne $i 0 -}}
/
{{- end -}}
{{ . }}
{{- end -}}
{{- end -}}
{{- if ne (len $uriParts) 0 -}}
/
{{- end -}}
{{- if and (eq $page.Protocol "gopher") (eq (len $uriParts) 1) -}}
{{- $uriLast = $uriLast | trimLeftChar -}}
{{- end -}}
{{ $uriLast }}
{{- end -}}