{{- $href := .page.RelPermalink -}} {{- if and (eq hugo.Environment "offline") (hasSuffix $href "/") -}} {{- $href = printf "%sindex.html" $href -}} {{- end -}} {{- with .from -}} {{- $directory := .RelPermalink -}} {{- if not (hasSuffix $directory "/") -}}{{- $directory = path.Dir $directory -}}{{- end -}} {{- $prefix := "" -}} {{- range split (trim $directory "/") "/" -}}{{- if . -}}{{- $prefix = printf "%s../" $prefix -}}{{- end -}}{{- end -}} {{- $href = printf "%s%s" ($prefix | default "./") (strings.TrimPrefix "/" $href) -}} {{- else -}} {{- $href = $href | relURL -}} {{- end -}} {{- return $href -}}