hugo-theme-relearn/layouts/partials/relBaseUri.hugo
2024-03-18 21:58:53 +01:00

10 lines
No EOL
435 B
Text

{{- /* generates an uphill path from the current page to the root of the server */}}
{{- $subdir := strings.TrimSuffix (relLangURL "/") (relLangURL "") }}
{{- $relBaseUri := .RelPermalink }}
{{- $relBaseUri = replaceRE "/[^/]*$" "" $relBaseUri }}
{{- $relBaseUri = replaceRE "/[^/]*" "/.." $relBaseUri }}
{{- $relBaseUri = trim $relBaseUri "/" }}
{{- if not $relBaseUri }}
{{- $relBaseUri = "." }}
{{- end }}
{{- return $relBaseUri }}